how to prevent object from going to parent origin

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

i am creating a new object for my game but when i put it somewhere in the level scene and then run the game the object teleports to its parent(root) origin but i havemany other objects in the scene that work fine it just keeps going to its parent position i am new to godot so thx in advance

:bust_in_silhouette: Reply From: Gluon

Can you confirm how you are setting the position at the moment?

Normally you would set its global position like this;

object.global_position = Vector2(int, int)

or you might have a position2d somewhere and you would do this

object.global_position = $Position2d.global_position

i am setting it from the editor (my node is a platform that gets destroyed when you stand on it for too long )so it doesnt move

moazdeyaa | 2022-12-29 06:16

If it is not going to move I suggest putting a position2d where it is going to be and using the line of code I mentioned above to set its position. Thats the easiest way.

Gluon | 2022-12-29 09:54

ok ill try thx

moazdeyaa | 2022-12-29 12:20