Hello, I am trying to create sprites of weapon and keep them “in the hands” of each enemy (so in other words I am trying to pin an instance of a weapon sprite on each spawned enemy). The problem is that I struggle synchronizing the location of each weapon with each enemy. I tried to implement this with an array but I didn’t manage to make it work. It takes the coordinates of only 1 enemy atm instead of all of them, so what happens is that only one enemy gets the weapon sprite synchronized to its location.
If anyone can give a tip to make that or fix my script I’d be very thankful
Here is the events sheet :
Here is the result as explained :
ok, so I did find out the way to solve the issue but I am not sure why my first event script doesn’t work.
So, apparently I have to use scene variables only (not object variables, it doesn’t work) AND I need to use the syntax “Variable(array)” instead of “SceneVariableFirstNumber(array)”. I have no idea why one syntax works and not the other one, and you can’t even find the right one in the function builder (I had to look for tutorials on the GDevelop YT channel).
anyway, here is the screenshot of solution (and if anyone knows why the 1st event script doesn’t work I’d love to have a proper explanation)
FirstNumber is pretty new i didn’t test it yet.
For now i don’t see anything wrong but i’ll get a try and see what i can find.
Even if you found a solution, i can still let you know that you can link objects to others :
It’s pretty handy for what you want to do.
Thank you very much, I didn’t know about the “link objects” action (I am new to Gdevelop, downloaded it this week). I can do the exact same thing with only 1 line so it’s much cleaner !
Great jobs, it helps me a lot