- Home /
Question by
Treven · Jul 29, 2015 at 11:54 AM ·
2drotationquaternionraycastinghit
My player is not Rotating as should
I have this code here that should rotate him but i dont understand why its not working. the ray is shooting at the ground and tested it it does and the hit.normal should rotate until it matches the hit's rotation.
Ray2D ray = new Ray2D(Vector2.zero, Vector2.down);
RaycastHit2D hit;
void Update () {
ray.origin = transform.position;
Debug.DrawRay (ray.origin, Vector2.down);
if (Physics2D.Raycast (ray.origin, hit.point))
{
transform.rotation = Quaternion.FromToRotation (Vector2.up, hit.normal);
//Debug.Log("isTouching");
}
}
Comment