Pick correct instance of an object

I have an object (cannon) and it fires a cannonball. I added the physics behaviour. When I shot a cannonball using the FireBullet Extension it gets created and a force will be applied (1 time) so the will move at the spcified angle for a distance and then fall with an angle.

Each time I fire a new cannonball (so a new object instance is created) the force is applied to all cannonballs on the screen, not just the one created. So the already cannonballs fired and still in the air will make a new “jump”. From what I understood shouldnt only the newly created object take all the actions from that event?

My goal is that only the newly created should have the force.

My questions: Do I have an error in my events?
In debugger I see each object has its own object variables

Can I somehow refer to the __Firebullet:BulletID Value?

The Screenshot shows that 1. ball gets 3 impules, 2. 2. and the last fired 1 impulse

Here my events:

Okay I found a solution on my own by creating a sub-event.

but -nonetheless- I would like to know If I can somehow directly refer to the object variables created wenn an object is created

:wave: Hi and welcome here :slight_smile:
If your bullets are physics, maybe you shouldn’t be using the bullet firing extension.
When you create an object with events, the actions right below the creation action will only apply to that newly created instance.
If you want to apply actions to one object at another moment, then you’ll have to refer to that specific instance with conditions (instance variable, position, Link, etc.)

Hi Gruk and thank you for the reply!

Well - the problem is that exactly that was what I would think is correct. But - with my chain of events - it is not.
I can show you a video of what happens:
I create a bullet - it flies away in an arc, the event is done. I create another one in a new event after 3 seconds - the SAME physics force will be apllied to the new - it flies away with force and arc - and the old object (same force and same arc again)
And that made me headache and even made me think that I may have found a bug.

To make a few things more clear - the cannonball is not having the bullet firing extension (that is only a behaviour of the firing boat)
Only the cannonball sprite is having physics 2.0

→ Okay I change the chaon from “Fire … cannonball …” to “Create object cannonball” and apply the force afterwards - that seems to work! Thank you for leading me in the right direction.

→ Unfortunately not working as expected as I loos the ability of the firing extension. So firing cooldown etc is not working anymore. I think I have to stick to my solution (right now)

Extensions are different than events. They’re designed to be more self-contained. Unless they use JavaScript, their picking or creating objects doesn’t make the objects “picked” like with normal events. You can test it by using the PickedInstancesCount(objectName) expression. Either display the value in the debugger log or in a text object.

Edit: just for clarity. You can use conditions to pick objects while in extensions but they don’t remain “picked” when it returns to the events that called it. I just wanted that part to be clear.

Hi, just to add to what Gruk and Keith already wrote, there is an example for canon balls with physics Cannon ball with physics - a game example from the GDevelop game making app | GDevelop. It does not use the fire bullet behavior and it works very straightforward without any additional instance picking.

This is all what you need: