First person combat pitch reset override?

Jaakk0S

New member
Hi!

Thanks for the awesome product and great support. I have gotten past my previous issues with help.

I am switching view type Combat -> Transfom Look -> Combat at runtime and struggling to get the character keeping his head straight when switching back to Combat. The pitch resets to 0. This is the first thing I tried:

this.cameraController.SetViewType(UnityEngineUtility.GetType(COMBAT_VIEW), true);
this.cameraController.ActiveViewType.Rotate(0, -30f, true)

This results in a (one frame?) flash where the pitch resets to 0, then rotates down. Not pretty.

Next thing I tried is to Reset() and Rotate() the Combat view before setting the view type. This has no effect - apparently the pitch is reset to zero somewhere in the code.

It gets quite complicated from this onwards, I tried extending Combat class but can't find a way.

I wonder if there's a proper way to do this?
 
I believe the pitch/yaw get reset to 0 if there's no current viewtype or character, in CameraController.SetViewType (starting at line 304). So maybe put a couple of logs in there to see if that's what's happening for some reason - e.g. if your character doesn't exist at the time of the transition, or the reference to it was null somehow.
 
Yes I remember got this far earlier debugging...

I added logs and can see that the viewtype is not null, so we go inside that if block, then after
pitch = m_ViewType.Pitch;
yaw = m_ViewType.Yaw;
both pitch and yaw are 0. So the zero comes from the viewtype which is Combat in this case.

I'm doing this:
this.cameraController.GetViewType<Combat>().Reset(Quaternion.identity);
this.cameraController.GetViewType<Combat>().Rotate(0, -30f, true);
this.cameraController.ActiveViewType.Reset(Quaternion.identity);
this.cameraController.ActiveViewType.Rotate(0, -30f, true);
this.cameraController.SetViewType(UnityEngineUtility.GetType(COMBAT_VIEW), true);
so, both the active and the combat view type pitch should be -30f but is not.

Seems to me that this line
m_ViewType.ChangeViewType(false, 0, yaw, characterRotation);
sets the pitch to literal zero.

And seems like a bug to me considering what the code looks like trying to do.
 
Found it.

My TransformLook had "Restrict Pitch" flag on which resulted in the Rotate() call being ineffective.

Disabling the flag fixed my issue.
 
Top