![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | EnchantedCat |
So i have a character that has an idle animation for each cardinal direction, and a running animation for each cardinal direction.
The idle animations are one frame, and the running animations are 6 frames.
When running the game, it displays the east+west running correctly, but for up+down, it just displays the idle animation.
Also, whenever i try to view any animation by playing it in the AnimationPlayer, it goes all glitchy and flashes between frame 12 and the frame it should be showing at random intervals. Manually changing the frame from frame 12 with the menu on the right just immediately sets it to 12 again.
I’m using the AnimationTree node to switch between animations.
Here is my code: (gdscript)
extends KinematicBody2D
const FRICTION = 500
const ACCELLERATION = 500
const MAX_SPEED = 80
var velocity = Vector2.ZERO
onready var animationTree = $AnimationTree
onready var animationState = animationTree.get("parameters/playback")
func _physics_process(delta):
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
animationTree.set("parameters/idle/blend_position", input_vector)
animationTree.set("parameters/run/blend_position", input_vector)
animationState.travel("run")
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELLERATION * delta)
else:
animationState.travel("idle")
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
velocity = move_and_slide(velocity)
print (input_vector)
Im positive it’s something simple that I just missed, I’m new to this engine and programming in general so any help would be appreciated!