I am using this code to orient the player to the slope of whatever is below it:
function Update () {
var hit : RaycastHit;
var castPos = Vector3(transform.position.x,transform.position.y-.25,transform.position.z);
if (Physics.Raycast (castPos, -transform.up, hit)) {
transform.rotation = Quaternion.FromToRotation (Vector3.up, hit.normal);
transform.rotation.z = 0;
}
}
This makes the player rotate to the ground. The thing is, it completely restricts their y rotation and you can only move forward/backwards (It is allows extremely trippy and jumps in wierd rotations at times). How do I release the y axis? I only really need the x to rotate up or down, with the z frozen.
Please, HELP… Thanks in Advance