Treat each occurrence of the same objects individually

Hello there !

I need help about dealing with many occurence of the same object (sprite).
I am creating a game in which many blocks of the same type (same sprite, lets say block1) go straight to a direction at the begining and are supposed to change their direction when they collide with a specific object (sprite of an arrow, could be UP DOWN LEFT RIGHT).

But once the first block1 of my chain collide with the arrow, all the occurence of this block1 sprite chance their direction.

How can I treat them individually please ?

Thanks a lot !

Can you past a screenshot of your events? Anything would just be a guess. You might need different conditions to filter just the right objects or a for each object event or 2. Instances take time to understand. You need conditions to narrow the focus of actions.

Thanks a lot for trying to help me ^^

Here is my first event. It release 60 different blocks (ame1, 2 ,3, 4, 5, 6) with several occurence of each.
Those blocks go right, its the default direcction.

And then, when they collide with a direction arrow, blocks need to follow this new direction.

Same reasoning for a bonusup, bonusleft or bonus right.

But like I’ve explained, when the first blocks (ame1) collide with the bonusdown arrow, all the blocks go down, even if they havent collide yet.


I know I have to treat them individually, but dont know how =p

It’s cute looking. Do they follow a path or just hit random arrows? Are the arrows always going to face the same direction? I’m not understanding the concept. Have you tried adding a permanent force instead of tweening? I’m just not clear what’s happening? Is the player placing the arrows?

As far as your current setup, I guess you could switch the scene variables to object variables. But when the objects hit an arrow, you might need to use a for each object.

My example. drag arrows with left mouse click, rotate with right mouse click.
I don’t like the way it collides but this might give you some ideas until we get some more details.

source:
doug13579/Gdevelop-objects-follows-arrows (github.com)

Edit: yes, you can use destroy when outside of the screen behavior to delete the objects. I didn’t know if they should bounce off the wall. So, I decided to just delete them.

Thanks for you kind words.
Your example is exactly what I am looking for !

They dont follow a path but go always straight to a direction, unless they encounter an arrow, placed by players. There are 4 kinds of arrows, UP DOWN LEFT RIGHT.

Those are basics bonus I am just trying right now. But I am going to add more of them, with different behaviour. Such as a warp/teleport bonus. In this case, blocks will keep moving the exact same way but will warp from an entry, to an exit.

1 Like