The Code provided, allows the object “from”, to rotate and look at the object “target”. However, I want to change it so that the object “from” rotates to look at “target” with frozen rotation on Y axis which means that it wont be able to directly look at it due to this restriction… This is actualy what i want, on the same note, I did try to add a ridigdbody and use the option “freez rotation on Y axis”, but that did not work, and i think that is because the script overwrites it…
I am a tottal noob at this
Please help me fix my code ![]()
public Transform target;
public Transform from;
void Update ()
{
Example();
}
void Example()
{
Vector3 relativePos = target.position - transform.position;
Quaternion NewTargetRotation = Quaternion.LookRotation(relativePos);
transform.rotation = Quaternion.Slerp(from.rotation, NewTargetRotation, Time.deltaTime * 1);
}
}