0 votes

Hey everyone,
I'm still new to Godot and I have been trying to create my first RPG game, but I have encountered some problems one of them is my character keep switching side when finished pressing the up or down button I'm currently using the Animationtree which stores the Idleleft and Idleright (i don't have an animation for the up and down movement I want to stick with two movements) I have added the Idleleft on the left the Idleright on the right and for the up I added Idleleft and down Idleright I also have run animation and attack animation that works just fine. it's only when I press the up button and my character is facing right he switches to the left side while moving up, and when he is facing the left side and I press the down button he switches to the right side while moving down

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)
    animationtree.set("parameters/Attack/blend_position", input_vector)
    animationstate.travel("Run")
    velocity = velocity.move_toward(input_vector * MAX_SPEEED, ACCELERATION * delta)
else:
    animationstate.travel("Idle")
    velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)

move()

hopefully, you find my question clear like I said I'm still new and I really appreciate any sort of help

Godot version 3.4.2
in Engine by (12 points)

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.