15 lines
493 B
GDScript
15 lines
493 B
GDScript
class_name Crate extends RigidBody2D
|
|
|
|
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
|