I have an object that spawns every “x” seconds at the top of the screen and then moves to a point down screen using a speed variable
once it reaches a point down screen the value of the speed variable is reversed and the object moves back toward the top of the screen
this is where I have a “problem” - once the 1st spawn object reaches the point and begins to move back up screen all the other newly spawned objects never make it down screen, they all immediately reverse and move up screen with the 1st object
I want each spawned object to complete the action of (1) spewing (2) move down screen (3) reach the designated point (4) reverse and go back up screen
how can I fix my issue??
I have tried using a nested “repeat for each object” but that doesn’t seem to work. any other suggestions??
Use the “For each object” event which is a special event that goes through each and every instance of the object and fire the event on each, one by one.
However, you want to be careful with this as it can be heavy on resources depends on what kind of conditions you check and on how many objects but it should solve your problem.
Another thing you can also try in case the “For each object” event uses too much resources is to use object variables to flag which direction the object needs to move.
For example say the name of the variable is “direction” and the value by default is 0.
So you can do something like
If Variable ‘direction’ of Object = 0 Then move Object down
If Object is down Then Do = 1 to Variable ‘direction’ of Object
If Variable ‘direction’ of Object = 1 Then move Object up
This way, by using an object variable you can be more specific regarding which instances should move down and which ones should move up…