What are you trying to reset? If it’s a rigid body then the physics engine will take precedence once you teleport it so it won’t work. You need to do it inside the RigidBody2D._integrate_forces()
function and modify the state.transform.origin
instead.
extends RigidBody2D
@onready var reset_pos = global_position
var reset = false
func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
if reset:
state.transform.origin = reset_pos
# Call reset_physics_interpolation() at the end of the frame once the physics engine has been updated
reset_physics_interpolation.call_deferred()
reset = false
func _on_area_2d_body_entered(body: Node2D) -> void:
if body == self:
reset = true
Result:
Left is being interpolated, right is not. I lowered the physics ticks per second to 20 in the example.