How to Change Object if it's Off Screen?


#1

Hey all,
I have an object spawner in my game that spawns objects offscreen. How can I make it so that, when a condition is met, it changes its animation ONLY IF it’s offscreen?
For example, if the object spawns at -200 (off screen) ok animation #1, I would like it to change it’s animation to #2 while it’s off screen, but not any other instances of the object EXCEPT the ones offscreen. How can I do so?


#2

As I already told you, add a condition if object.Y() <= -200

For this, you need: http://wiki.compilgames.net/doku.php/gdevelop5/events/foreach


#3

i’m aware that you’ve said this before :slight_smile:
i just didn’t know how to exclude iterations of an object that were not offscreen. in this case, how would i structure an event that goes like this:
(for each object above the point -200) -> (change animation to #2)?


#4

That sounds right, but that depends on what you’re trying to achieve, of course.
I fail to see the point of spawning objects offscreen with an animation that you don’t want…


#5

Perhaps I’ll try a different way, but thank you for your help