21 lines
515 B
GDScript
21 lines
515 B
GDScript
extends Node3D
|
|
|
|
|
|
@onready var ball = owner
|
|
@onready var mesh = get_node("tail")
|
|
|
|
|
|
func _process(delta):
|
|
# Align the tail to the linear velocity
|
|
look_at(ball.linear_velocity + ball.global_position)
|
|
|
|
shrink_tail()
|
|
|
|
|
|
func shrink_tail():
|
|
# Set the blend shape value to how much the ball is squished
|
|
# A power of 0.5 makes the shrinking effect more apparent
|
|
var factor = pow((1 - ball.mesh.scale.z), 0.5)
|
|
var blend_shape = mesh.find_blend_shape_by_name("Shrink")
|
|
mesh.set_blend_shape_value(blend_shape, factor)
|