Preventing an object from spawning off-camera

MonjiOMonjiO Member Posts: 20
edited November -1 in Working with GS (Mac)
So, I'm working on a shooter game and I'm trying to prevent enemy attacks from coming from offscreen, while still destroying themselves once they reach the edge of the screen. I've got the camera as an object with its own dimensions and it is detected for the purposes of player movement.

Detailed Explanation:
The player is moving from left to right, with enemy projectiles coming from right to left. Currently, I have a rule stating:

If self.position.x < game.CamOriginX
Then Destroy Actor

So the projectile is destroying itself once it hits the left edge of the screen. However, currently, enemies are able to attack based on timers meaning that attacks can (and are!) coming from outside the camera range.

So, my question is basically how best to prevent this sort of behavior. Should I redo how enemies are attacking so that they won't attack while offscreen? If so, how? Or is there a way to make the projectile destroy itself while not in the camera's view?

Comments

Sign In or Register to comment.