You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
720 B
GDScript

extends Node
class_name PlayerDash
func run(actor, delta):
actor.getAnimatedSprite().animation = "dash"
actor.getAnimatedSprite().speed_scale = 2.5
var velocity = actor.last_process_velocity
velocity = velocity.normalized() * actor.speed
if velocity.length() > 0:
actor.getAnimatedSprite().play()
actor.position += velocity * delta * 1.8
actor.position.x = clamp(actor.position.x, 0, actor.get_viewport_rect().size.x)
actor.position.y = clamp(actor.position.y, 0, actor.get_viewport_rect().size.y)
actor.getAnimatedSprite().flip_h = velocity.x < 0
func spriteFinished(actor):
actor.state = actor.PlayerState.STANDING
actor.getAnimatedSprite().flip_h = false
actor.getAnimatedSprite().speed_scale = 1