I’m trying to make my player character turn around after running to either left or right
I have a running animation, turn around animation, and an animation tree set up
But I’m having trouble figuring out how to make the character turn around animation play at the right time. I’ve tried a couple of different blendspace1d setups but cant get it working
I was wondering if a blendtree could work but I’m not that familiar with it or if there would be another solution
Now, I’m a complete Godot beginner and have no idea what a beldtree is.
But here is my approach to it.
# var oldDirection saves direction from last frame
var direction := Input.get_axis("left", "right")
if direction:
velocity.x = direction * SPEED
#sprite flip
if direction > 0 && oldDirection < 0 :
animated_sprite_2d.play("turn right")
if direction < 0 && oldDirection > 0 :
animated_sprite_2d.play("turn left")
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
Then your animations for turn left / right just must be quick for it to look good.
I don’t know if this was even remotly helpfull but “Any and all help is appreciated” is everything i saw xD
I can see what you are trying to do with the code and i think that with some tweaking it could work very well but i’m already using an animationtree and i don’t want to switch the way the player is animated and i don’t really know how i would implement this into what i currently
Hi, what do you mean by “turn around after running to either left or right”? Do you mean that they will stop running and play a turn around animation? When is the turn around animation triggered? Is the turn around animation and the running animation in the same BlendSpace1D?
I’m not sure i understand completely but i think yes and the reason this dosent work is because the blendspace1d blend_value is dependent on the players direction.x value so when going from one direction to the other it triggers all animations in the blendspace1d the problem here is that I also have my idle animation in the middle (blend value 0.0)
I’ve been thinking about discarding the blendspace1d idea and trying to see if something else could work
I don’t know if you have any experience with blendspace1d but an idea I had was to implement two extra blendspace1d inside the blendspace1d so the node would look sort of like this:
And as mentioned before my first blendspace1d blend value is dependant on player direction.x but will my two other blendspace blend values also depend on player direction?
And if not how would i call their blend_value parameters?