(Solved) Object variable in action, not working as expected

How do I…

Make the fire action (of firebullet extension), take the speed from the object variable.

What is the expected result

When the bullet is fired, to go in that direction.

What is the actual result

The bullet is created, but without speed

Related screenshots

First the setup, I created a bullet object
And add Speed as object variable

Then when I want to shoot, I use “FireBullet” extension, action “Fire bullet towards an angle”.

If I change to static value, it works; but when I try to use the object variable, the bullet its created, but it doesn’t move

I don’t know if its because its an object that its not instantiated and I should use global variables or I still don’t understand object variables.

Thank you for your time.

Yes, this is why. You are referencing the variable of an object that doesn’t exist yet. The YellowBullet object in the action has not yet been created when the fire bullet action is called.

Instead, use a global structure with the child name the same as the object’s name, it’ll make life a lot easier. Something like:

1 Like

That was quick, thanks a lot, I’ll do that.

Like you say, it was because reference, I even made it work in a hacky way.

First I add an instance of a bullet in the scene, but that don’t work as expected.

Then I add a local variable, that take the speed of that instance, and now it worked, but honestly that was to much.
[/quote]