- Home /
AI 2d sprite animation in 3d isometric realm based on direction
Currently I am trying to have an AI change an animation based on the direction it is going. Essentially it has 4 movement animations, one in each direction. It constantly is chasing the player (a specific point that gets updated), but I am not exactly sure how to make it change animation without an input. I've been trying to compare positions or vector3 velocity, but I don't really know the best way to go about it and actually make it work. Any insight on best practice or a good method to do it would be fantastic!
Use parameters! Link them in a script. You can control an animation using any variable this way.
You can change your walk speed based on how much red there is in a colour!
Well then the question is what types of parameters to compare to one another. I already tried two different positions and two different vector3's.
So if I'm reading this right, you have an enemy gameobject, and you have it moving, but somehow you don't know the direction it's moving in?
If you cannot access your move direction vector for some reason, you could subtract your previous object position from your current one to get it. Then, assu$$anonymous$$g you have 4 move directions (up, down, left, right or something), you could say something like (pseudocode) if moveDir.x > 0 do up animation else if movedir.x < 0 do down animation else if movedir.y > 0 do left animation else if movedir.y < 0 do right animation else do idle animation
That's probably not really the best way to do it, but it's as far as I can get without knowing more about your implementation.
I think that idea might actually work well! I am relatively new to vector math, but looking at it again that seems like a good way. I was going to subtract the enemy object position from the character's (the target)
Your answer