Hey Chris,
Been looking into limiting the players yaw to a certain radius when in first person for conversations and certain scenarios.
Delving into the code on the first person camera, it notes the yaw control is controlled in the player script. Is this correct? Just making sure before I start looking how to customise it.
Trying to avoid writing a completely new motion controller as the supplied one is pretty much perfect except for limiting yaw and possibly jumping
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
The yaw is determined by the Player's facing direction, yes. When you look left and right, you're essentially just turning the Player.
If you wanted to limit the yaw, you'd have to also limit the Player. A custom script that reads the Player's angle and sets it to a constrained value by calling SetRotation in LateUpdate should do it.
Alternatively, you could temporarily set the Player's Motion control field to Manual, so that you then have total control over the Player's rotation through script.
Feel silly now that I found today theres something is written with pretty much exactly what I want to do! Haha
https://adventure-creator.fandom.com/wiki/Camera_-_Constrained_first-person
Although I did take a punt at trying to write something myself. I managed to get the players angle, but I was not able to trigger setRotation
I kept getting the error
An object reference is required for the non-static field, method, or property unity
I believe I am just not writing it out AC.Char.SetRotation(maxRotationY); Correctly.
What is the correct way to call it? I am still pretty fresh to learning coding, so I'm struggling to figure out how to us AC commands. Never sure to use Kickstarter. or otherwise.
}
Code works except for the AC command
AC.Char is a class - not a reference to the class instance, i.e. the character themselves.
The Player character can be accessed with:
So the equivalent would be:
Thank you, works perfectly!