I have an object that rotates to match the collider’s normals. I don’t want the collider’s normal to determine what the Y axis rotation should be. Instead, I want the Y axis to rotateTo to desired position in space.
Vector3 lookAtPos = new Vector3(1,2,3);
RaycastHit hit;
Ray ray = new Ray(transform.position + (transform.up*0.75f), -transform.up);
Collider col = GameObject.Find("wall").GetComponent<Collider>();
if (col.Raycast(ray, out hit, 1f)) {
transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;
}
The idea is to have the object walk on walls while looking at moving object with the Y axis. Any ideas of how to finish this code?