Character Won't Idle In Correct Direction
Hello! I'm following a tutorial on how to create a top-down 2d RPG right now. It's working well - my character walks in the correct directions and all that jazz. However, the issue arises when he stops walking. No matter what direction I was moving in before, he always returns to the idle position facing towards the camera instead of right, left, or up. I'm a bit puzzled since my blend tree seems to be working fine and I'm also fairly certain that I copied the script down correctly. How can I make my character idle in the correct direction? Here is a screenshot of my script. I have screenshots of my transitions, if needed too but it wouldn't let me add them :^(.
So, here's a description instead. Let me know if you have questions! I have two blend trees, one for idling and one for movement. idle -> movement has 4 different transitions, the only difference between them being that for conditions, one is moveY is greater than .1, one is moveY is less than -.1, one is moveX is greater than .1, and one is moveX is less than -.1. My movement -> idle only has one transition, but it has four conditions: moveY is less than .1, moveY is greater than -.1, moveX is less than .1, and moveX is greater than .1.
Again, I apologize for throwing a lot of this information at you without screenshots! Thank you in advance for the help.
Answer by Rynbernsz · Dec 09, 2019 at 06:24 PM
You could keep track of what was last done as input/movement, and then update your lookDirection to this value. I can't see where your lookDirection is being used, but that's what may be being called after your RawAxis becomes 0 or you're not putting in a direction for movement.
Alright, cool! So, how would I go about doing that, like what would I put in the code and where? Sorry, I'm super new to C# :,^)
Your answer
![](https://koobas.hobune.stream/wayback/20220612215907im_/https://answers.unity.com/themes/thub/images/avi.jpg)