Skip to content

Correct way to access the CogitoPlayer #202

Closed Answered by Phazorknight
DavidBradbury asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, welcome and so glad to hear Cogito has been useful for you.
In general, the CogitoSceneManager autoload saves a reference to the player node, which can be used in a pinch.

I'd recommend taking a look at the Security Camera script, but basically it works like what you seem to have already going for your enemy:

  • Area3D is checked for body_entered / body_exit signal (and filtered for nodes in group "Player")
  • For as long as Player is within Area3D, a raycast check is performed to see if the Camera can "see" the player. This is done by casting a Raycast3D from the Camera to the Player and seeing if it hits the player or something else.
  • If the Player is visible for the Camera, it gets swit…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DavidBradbury
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
documentation Improvements or additions to documentation
2 participants