Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Blue_aei |
My motion gets stuck on scrolling, as long as velocity != vector.ZERO it breaks the scrolling animation and plays the moving animation.
func _process(delta):
match state:
MOVE:
move_state(delta)
ROLL:
roll_state(delta)
rotate(delta)
func roll_state(delta):
velocity = roll_vector * ROLL_SPEED
animationState.travel("Roll")
move()
func rotate(delta):
var dir = Vector2(1,0).rotated($Gun.global_rotation)
dir = (dir / 3.14)*180
if dir.x <= 35 and dir.y >= -35 && dir.x <= 35 and dir.y <= 35:
if velocity != Vector2.ZERO && Input.is_action_just_pressed("Roll"):
animationState.travel("Run")
if Input.is_action_just_pressed("Roll"):
roll_state(delta)
else:
animationState.travel("Idle")
$Gun.flip_v = true