31 lines
846 B
GDScript
31 lines
846 B
GDScript
extends RigidBody3D
|
|
|
|
var death_direction = Vector3(0,0,0)
|
|
|
|
@export var mesh : Array[Node3D]
|
|
@export var colliders : Array[CollisionShape3D]
|
|
|
|
var alpha = 0.3
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
# Killed
|
|
if death_direction != Vector3.ZERO:
|
|
# No longer moves!
|
|
linear_damp = INF
|
|
|
|
for mesh_animation in mesh:
|
|
# Melts the mesh
|
|
mesh_animation.scale = mesh_animation.scale.lerp(Vector3(0,0,0), 1 - alpha ** delta)
|
|
|
|
# Absorbs
|
|
mesh_animation.global_position = mesh_animation.global_position.lerp(mesh_animation.global_position + death_direction, 1 - alpha ** delta)
|
|
|
|
for collider_animation in colliders:
|
|
collider_animation.disabled = true
|