Hi!
Relevant script elements:
- Third Person Vcam “AimCam”
- FollowCam followCam"
- GameObject " _followTarget", same use as in the tutorial, where the AimCam follows it as the player controls its rotation
I used the unity Tutorial to implement a 3rd person controller, but I would like to the player to smoothly rotate to the follow target’s forward rotation as opposed to snap.
I was able to make this work by implementing a FreeLook camera, and using the following code (only when the player is moving forward or back):
var projectedCameraForward = Vector3.ProjectOnPlane(Camera.main.transform.forward, Vector3.up);
var targetAngle = Quaternion.LookRotation(projectedCameraForward, Vector3.up);
_followOffensiveTarget.transform.rotation =
Quaternion.RotateTowards(_followOffensiveTarget.transform.rotation, targetAngle,
playerTurn * Time.deltaTime);
The problem that this introduced was that the FollowCam will remain in its last position after I switch to the AimCam, and so when I switch back to the FollowCam, it’s facing the “wrong” direction and leads to wonky transitions. For the life of me cannot get it to just reset behind the player.
I believe the solution is something like
freeLook.m_XAxis.Value = [insert player’s vector somehow from a project plane], but I cannot figure out how to actually code it.
Any ideas would be great - I’ve burned so many hours trying to figure this out.
Thank you in advance!
