Hello,
in my 2D Top Down Game i have my hero controlled by moving to the “RightMouseClick”.
To make now animations for walking up/down/left/right is it possible to read any vector for the direction of the moving Character to get the right transitions for my animations ? I use the AI Path script …
How can i get the direction vector or are there any other ideas to solve this?
1 Like
Hi
You can subclass the AIPath script and set the animations from there.
Something like
public class MyAI : AIPath {
protected override void Update () {
base.Update();
if (Mathf.Abs(velocity.x) > Mathf.Abs(velocity.y)) {
// Either left or right
if (velocity.x > 0) {
// Use 'Right' sprite
} else {
// Left
}
} else {
// Either up or down
if (velocity.y > 0) {
// Up
} else {
// Down
}
}
}
}
2 Likes
fantastic!
Thank you very much!