Right now I’m trying make the hovering vehicle align itself to the road beneath it but maintain freedom of steering (think of a car going over a twisting hill - it rolls and pitches according to the surface underneath it, but the yaw depends on the direction of the craft). The game is in 3D, obviously.
I think the problem in my current code is that it doesn’t account for the relative rotation of the object, only the world rotation value? I’m not sure if that makes sense.
Here is the alignment code so far (please tell me if you need to see anything else!):
if (Physics.Raycast (downRay, hit)) {
var alignment = Quaternion.Euler(hit.transform.rotation.eulerAngles.x, 0, hit.transform.rotation.eulerAngles.z);
transform.Rotate(alignment.eulerAngles * Time.deltaTime);
}
On top of this, I can’t get the model for the vehicle to be properly aligned. Right now to face forward the model is rotated 270 degrees on the x axis.
If you don’t want to answer but could point me to something I could read to help me understand, that would be appreciated as well! Thank you.