MarchGame/scripts/crate.gd

15 lines
493 B
GDScript3
Raw Normal View History

class_name Crate extends RigidBody2D
2026-03-09 20:48:04 +00:00
var teleport_target: Vector2 = Vector2.ZERO
var should_teleport: bool = false
func teleport_to(position: Vector2):
teleport_target = position
should_teleport = true
# called during physics processing, allowing you to safely read and modify the simulation state of a RigidBody2D
func _integrate_forces(state: PhysicsDirectBodyState2D):
if should_teleport:
state.transform = Transform2D.IDENTITY.translated(teleport_target)
should_teleport = false