Please make sure to always call set_pos
and set_global_pos
inside a fixed process for physics objects, even when resetting them. See the docs.
This is a very common pitfall when dealing with Godot physics. It tricked me more than once.
Example:
var should_die = false
func _ready():
set_fixed_process(true)
func reset():
should_reset = false
set_global_pos(Vector2(0,0))
func _fixed_process(delta):
if should_reset:
# CORRECT
# Will always work
reset()
# WRONG
# Might not work
# same goes if called from _process or input signal/_input callback
call_deferred("reset")
EDIT: The same apply for set_linear_velocity
set_angular_velocity
. Setter and getters alike (you might get incorrect values from getters outside of the fixed process).