Topic was automatically imported from the old Question2Answer platform.
Asked By
xtuneon
So, Im pretty new to Godot and Im making a Top Down game like Zelda except I want my sprite to be able to look only to left or right. I have that setup but my problem is that when I walk left and stop the idle animation is facing right. Same if Im facing left and going up and release left my character switches back to right, like it prefers to face right when going up or down. I know I have to store my direction in a variable and then tell the game to face that stored direction or something similar. Im using godot for only like a month and need help with this. If you find a tutorial or a guide on how to do it please tell me. Or you can tell me yourself. If you need any more information like screenshots or code please let me know.
Well I dont know how you have written this at the moment but I assume you have an animated character set up? I will assume below that there is a character with four animations which i will call AniLeft, AniRight, AniUp, AniDown. Obviously you will need to change it to suit what you have named your animations.
Func process(delta):
var vel = vector2.zero
if input.is_action_pressed(“ui_left”):
vel.x += 1
if input.is_action_pressed(“ui_right”):
vel.x -= 1
if input.is_action_pressed(“ui_up”):
vel.y -= 1
if input.is_action_pressed(“ui_down”):
vel.y += 1
move_and_slide(vel.normalized() * 100)
personalAnimationControl(vel)
so the above shouldnt cause the problem you are seeing at least but I dont know how different that is from your code?
Hello,
Im sorry I didn’t put any more information. Im using an AnimationPlayer and my character has only one running animation and then I flip the sprite even though its an rpg. I like this kind of style. And my movement is setup with an input_vector like this: