Hi, I've got a simple problem. I'm struggling to create an RTS game. In it, one must be able to click a unit and move it to a set position. After working all day, I've gotten pretty far, and I'm almost done. What I've done is on mousedown, create an invisible sphere at hit.point (using raycast.hit). The unit targets the sphere, and walks towards it. However, since the sphere is on the ground, the unit will rotate towards it until it is directly over it, at which point, it will be directly over it, and to continue facing it, will rotate until it is horizontal to the ground. This constituted a major problem in my development, as it was completely unrealistic. I sought to counter it by placing a Configurable Joint on my unit. However, the unit simply could not get to the target, because it wanted to rotate, but couldn't because of the C. Joint. It would therefore stop at some distance from the target. How would I fix this?
Thanks in advance - Elliot Bonneville.
P.S. Thanks go to all the people who have already answered my previous (numerous) questions.
Putting the configurable joint just makes things more complicated. Why don't you disable the lookAt as soon as you enter the sphere and solve the rest by just approaching a location which is at a point which you calculate like [sphere center on ground] + [y-value of pivot point of the moving unit]. You just keep moving the last short distance towards that point above ground and no turning downwards will occur.
You could look into UnitySteer and the simple MovesToPoint vehicle as an example. Sounds like part of the problem is that the target you're attempting to look at is at ground level, when you should instead be looking at a point that is, so to speak, at "eye-level" for the unit. It's likely all you need is simply adjusting the Y of the target.
Update: Just noticed that's what Kvante said, and upvoted. Leaving the post up as the steering reference is still relevant.