- Home /
Question by
junglejapes · Nov 14, 2013 at 10:15 PM ·
rotationraycastquaternionraycasthitslerp
Raycasting and changing player rotation accoording to what is underneath.
(Physics.Raycast(transform.position + Vector3(-1,0,0), -Vector3.up,hitA, 100)); var targetRotation = Quaternion.LookRotation(hitA.transform.forward,hitA.transform.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 10 * Time.deltaTime);
so what is happening is my character is above slanted ground he rotates his right side right to the ground. where he should be rotating left so his feet touch it.
Comment
GOT IT!
var targetRotation = Quaternion.LookRotation(Vector3.Exclude(hitA.normal, transform.forward), hitA.normal);