Quantcast
Channel: Questions in topic: "unit"
Viewing all articles
Browse latest Browse all 68

Rotate unit while taking terrain into consideration

$
0
0
I have vehicles in my game that need to have their y rotation value adjust based on the terrain underneath them. When driving uphill, my units y rotation will be incorrect. This is what I currently use to rotate my unit. Quaternion rot = Quaternion.LookRotation(targetDir - unit.transform.position); float rotateVelocity = Mathf.Min (3.0f * Time.deltaTime, 1); unit.transform.rotation = Quaternion.Lerp(unit.transform.rotation, rot, rotateVelocity); To visualize what I mean, here an image: http://answers.unity3d.com/storage/temp/17661-exampleimg.png What I effectively need to do, is to get the coordinates of the mesh of the terrain at the front of my unit, and the back, but how do I accomplish that?

Viewing all articles
Browse latest Browse all 68

Trending Articles