I’ve got a character that moves from one point via mouse click - problem is he needs to turn to face the correct direction as he starts walking.
I’m sure this has been done before (i.e. a kind of “move to” function that reorients and transforms an animated character). There will need to be some kind of pathfinding, but I’m not too worried about that now - just a simple turn and move would be enough.
Is there anything out there already, or should i start coding it from scratch?
Yea, I’ve got the direction and movement code going OK - and there are loads of examples, I’ve read most of them
What I was wondering is if someone else has a complete implementation of a RTS style character movement script (with or without pathfinding) mostly to be able to compare notes.
There are a lot of examples for keyboard controlled FPS style games, but not so many for 3rd person click and move.
Your basic idea here is to use lerp between the characters current rotation and the rotation you get from looking at the point you want to go to. You’ll probably find the rotation and then set two of the axis back to what they were so your whole character is only turning on one axis. Probably y.
thanks - I’m doing that now by casting a ray, getting the hit point and then rotating the character toward that point using Quaternion.Lerp.
Problem is that in 2/3rd’s of the rotation he looks at the correct point, the other 1/3rd he doenst look directly at the point, and is off by about 20 - 45deg.
Also, to get your direction vector to pass to the above code, you can also just subtract the character’s position vector from the target’s position vector. That will also give you the distance to the target in the vector’s magnitude.