unable to set global_position of node

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

so i have a node, i try to set his global_position via normal Node.global_position = Vector2(x,y) . But there is a problem - nothing happens when i try to execute the command. Node is not null, Vector2(x,y) is not null, command even gives a error if i make Vector2(x,y) as null. I can get the value of Node.global_position but cant set it, nothing happens when i try to do that. Same applies to Node,position. Any idea how to fix it?

What is the node’s type?

CollCaz | 2023-05-27 11:50

Node type is Rigid Body

vania23 | 2023-05-27 12:13

:bust_in_silhouette: Reply From: CollCaz

So you aren’t actually supposed to set the position of RIgidBody nodes like that as it could lead to unintended consequences, I assume this is one of them, you instead would have to use some other function to do what you want to do.

If you only need to place a rigid body once, for example to set its initial location, you can use the methods provided by the Node3D node, such as set_global_transform() or look_at()

if you need to manipulate the position during game play you can do so in the _integrate_forces() callback. Example

There are more things i haven’ t mentioned but i hope i set you in the right track and good luck!