GrappleTest/Player/BasicCharacter/AnimationController.gd
Bingus_Violet 14ef7ad7f9 test
2024-02-22 00:10:13 -06:00

39 lines
827 B
GDScript

extends Sprite2D
@onready var player = $"../"
func spin(veloc, delta):
var vertSpinMult = abs(veloc.y) * clamp(veloc.x, -1, 1) / 1.5
var spinFactor = (veloc.x + vertSpinMult) / 20
if player.direction:
rotation = lerp(rotation, rotation + (spinFactor), delta)
else:
rotation = lerp(rotation, snappedf(rotation + (spinFactor * delta * 2), PI / 2), delta * 10)
var landed = 0
func _process(delta):
var velocity = player.velocity
var floored = player.is_on_floor()
print(scale)
if not floored:
spin(velocity, delta)
landed = velocity.y
scale = Vector2.ONE
else:
rotation = 0
if landed:
scale.y = 1 - (landed / 800)
scale.x = 1 + (landed / 800)
landed = 0
scale.y = lerp(scale.y, 1.0, delta * 10)
scale.x = lerp(scale.x, 1.0, delta * 10)
offset.y = (8 * pow(scale.y, -1) - 8)