cawez_puzzlebox/primitives/sticky.gd
2024-06-22 18:04:25 -04:00

18 lines
501 B
GDScript

extends Area3D
var stuck = null
var alpha = 0.01
# Called when the node enters the scene tree for the first time.
func _ready():
body_entered.connect(_on_area_entered)
func _physics_process(delta):
if (stuck != null):
stuck.global_position.x = lerp(stuck.global_position.x, global_position.x, 1 - alpha ** delta)
stuck.global_position.z = lerp(stuck.global_position.z, global_position.z, 1 - alpha ** delta)
func _on_area_entered(body : RigidBody3D) -> void:
stuck = body
print ("stuck!")