0 votes

I need to copy Vector3 to a variable. But in this code Vector3 (0,0,0) is always passed.

var old_bomb = merge_block.get_node("Bomb")
var trans = (old_bomb.translation)
Godot version stable 3.3.3
in Engine by (34 points)

Are you sure old_bomb.translation is not actually (0, 0, 0)?

It is also encouraged to use queue_free() instead of free() unless you have a specific reason not to.

The object is removed and vector3 becomes the default (0,0,0). Because, as I understand it, it is not a value that is passed to a variable, but a reference to the value. After deletion, the reference becomes null and the value of vector3 is reset. I need to use these coordinates after deleting an object, but I don't understand how to copy these values.

Are you sure old_bomb.translation is not actually (0, 0, 0)?

I will check it.

I'm an idiot. I took the wrong position. Apparently at night it is not worth writing anything, the attentiveness is poor.

1 Answer

0 votes

Pass old Vector3 component to Vector3 constructor to create new Vector3.

 var trans = Vector3(old_bomb.translation.x,  old_bomb.translation.y, old_bomb.translation.z)
by (889 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 Frequently asked questions and 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 [email protected] with your username.