0 votes

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?

Godot version v3.2.3.stable.official
in Engine by (23 points)

1 Answer

0 votes

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.

by (2,276 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.