- Home /
Question by
MontyMomentum · Aug 14, 2020 at 07:47 PM ·
rotateparentlookatlookrotation
LookAt script locks Z axis when parent is rotated
I'm using a simple LookAt script but the Z rotation gets locked when it's Parent is rotated 90 degrees on the Z axis.
Here's my script
using UnityEngine;
// This complete script can be attached to a camera to make it
// continuously point at another object.
public class PointAt : MonoBehaviour
{
public Transform target;
void Update()
{
// Rotate the camera every frame so it keeps looking at the target
transform.LookAt(target);
// Same as above, but setting the worldUp parameter to Vector3.left in this example turns the camera on its side
transform.LookAt(target, Vector3.left);
}
}
Comment