set_translation via array goes to wrong place

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RadRx

In our game, I set the location of an array of attacking ships:

var attacking = []
for i in range (att_ships)
    var position = Transform()
    --code to define x, y, and z ---
    attacking.append(Vector3(x, y, z))
    position = position.translated(attacking[i])
    $Attacking.multimesh.set_instance_transform(i, position)

The ships seem to display correctly, and the attacking array seems to correctly record their location.

However, later when the ship explodes, the ship disappears correctly, but the explosion particles go to the wrong place:

att_ships -= 1

I have read a bunch of documentation, have tried several alternative ways of moving spatial node, and have been staring at this for hours. What am I doing wrong?

:bust_in_silhouette: Reply From: Lopy

attacking[att_ships] is already a Vector3, the Vector3() around it can only hurt.

Are you sure that attacking[att_ships] represents the right ship? From you code, it seems like it references the last ship added, but that may not be the right ship.

Another possibility is that $Attacking has a non-0 translation, offsetting all the ships.