So, I’m trying to make my object’s y-axis match my camera’s y-axis, and for some reason the Rotation component doesn’t change when my camera changes.
My VERY SIMPLIFIED code:
public class MovementControllerWalking : MonoBehaviour
{
// Camera Entities
public GameObject cameraObject;
public Quaternion cameraRot;
// Player Entities
void Update()
{
cameraRot = cameraObject.transform.rotation;
GetComponent<Transform>().rotation = new Quaternion(0.0f, cameraRot.y, 0.0f, 0.0f);
}
}
Transform is accessible from every [Component][1] so you should not do a
– MrpxlGetComponent<Transform>()on any object. Instead you can just call "transform". [1]: https://docs.unity3d.com/ScriptReference/Component.html