Hi there, I’m a little confused as to why a simple bit of code won’t work and I’m wondering if I’m missing some key info on Cinemachine and how it works.
I have a first person cam setup, with ‘Do Nothing’ for body and Aim is set to POV. Simply, all I want to do is rotate my character in its Y rotation to match that of the camera, so the player’s body is looking at what the camera is. I’m calling this in LateUpdate()
private void LateUpdate()
{
transform.rotation = Quaternion.Euler(transform.rotation.x, CinemachineCore.Instance.GetActiveBrain(0).ActiveVirtualCamera.Follow.rotation.y, transform.rotation.z);
}
This script is attached to the player, there’s only one CM Brain, nothing else is changing the players movement/rotation so I’d assume it would work but does nothing. To test I also swapped: CinemachineCore.Instance.GetActiveBrain(0).ActiveVirtualCamera.Follow.rotation.y
for: Camera.main.transform.rotation.y
…and the result was the same. Out of desperation I did a quick test and switched out the rotation code out for:
private void LateUpdate()
{
transform.forward = Camera.main.transform.forward;
}
And it works as expected (though obviously rotates the camera on all axis which isn’t what I’m after).
Any ideas where I’m going wrong here?
Thanks!