0 votes

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! :)

Godot version 3.3.2 stable
in Engine by (12 points)
retagged by

1 Answer

0 votes

If animations and jumping from one to another even inside editor, it could mean you have too much activated at the moment.

Check both AnimationPlayer and AnimatinTree if there is multiple active and running animations.

by (195 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.