Godot Version
4.3
Question
I am new to Godot and am probably making some stupid mistake. I want to be able to instantiate objects with Rigidbody2D in a given place similiar to how it is done in this example godot-demo-projects/2d/instancing at 3.5-9e68af3 · godotengine/godot-demo-projects · GitHub
However I just cannot get it to work - I can intantiate an object at (0, 0) but cannot change its position.
The function for changing objects position is simply this:
func place(pos : Vector2, normal : Vector2) -> void:
global_position = pos + normal * size.dot(normal)
I’ve also tried to use set_deferred like this:
func place(pos : Vector2, normal : Vector2) -> void:
set_deferred("global_position", pos + normal * size.dot(normal))
And I’ve tried executing this code in a _physics_process as well.
The behaviour I am getting is that the object just blinks to the proper position for one frame before going back to it’s original position.
I have read that I shouldn’t set rigidbode_2d position directly but I can’t find any other way to do it.