Start shooting when an opponent enters camera view

Hi, I am making a top down shooter and spawning enemies outside of the player view. Those enemies then walk towards the player. I want to make it so that there is a check for is an enemy in camera view and if there is, start shooting where the cursor is. Stop shooting if there is no enemy on screen. Can anyone tell me what node or nodes can accomplish this?

If I remember correctly Rama’s Victory Plugin has a node called something like “isRendered” or “isOnScreen”


Alternatively, math it out with dot product and camera frustum. :innocent: Handy if you wanted more granular control over the desired cone of vision.

1 Like

Oh wow, I couldn’t remember that it was a default node.

Almost sure the node is his pull request. Rama was contributing heavily for years.

Thank you very much! This is exactly what I was looking for.

I just realized I was actually wrong about that solving it. My bullets fly whenever they are placed in the scene with this, even if they aren’t in view. Am I making a mistake?

In case this helps someone. I am not sure it is efficient. I am a begintermediate developer, but I got it working as intended like this:

I would welcome a better approach.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.