Add third-person camera.#786
Conversation
dooly123
left a comment
There was a problem hiding this comment.
Please also update to the latest developer
| /// </summary> | ||
| private void SimulateThirdPerson() | ||
| { | ||
| if (!BasisDeviceManagement.IsUserInDesktop() || CameraInstance == null) |
There was a problem hiding this comment.
CameraInstance will never be null?
There was a problem hiding this comment.
Oh okay, I wasn't sure
| { | ||
| if (!_wasThirdPerson) return; | ||
|
|
||
| transform.localPosition = Vector3.zero; |
There was a problem hiding this comment.
transform.setlocalpositionandrotation instead
| private void UpdateThirdPersonTargets(Transform parentTransform, float scale, float dt) | ||
| { | ||
| Vector3 targetTrackingPos = parentTransform.position; | ||
| float targetPitch = parentTransform.rotation.eulerAngles.x; |
There was a problem hiding this comment.
rotation. Euler converts it into a Euler (math), we then do that 2x
| Transform parentTransform = transform.parent; | ||
| if (parentTransform == null) return; | ||
|
|
||
| float dt = Time.deltaTime; |
There was a problem hiding this comment.
we should be parsing down the delta time from BasisEventDriver
| } | ||
|
|
||
| transform.position = desiredWorldPos; | ||
| transform.rotation = desiredRotation; |
| private void ApplyThirdPersonTransform(float scale) | ||
| { | ||
| float zoomT = Mathf.InverseLerp(ThirdPersonMinZoom * scale, ThirdPersonMaxZoom * scale, _currentCamParams.distance); | ||
| CameraInstance.fieldOfView = Mathf.Lerp(ThirdPersonMinFoV, ThirdPersonMaxFoV, zoomT); |
There was a problem hiding this comment.
this overrides users fov control are we sure we want todo this?
There was a problem hiding this comment.
Third-person FOV should be seperate from first-person FOV, I'll make it configurable with the other camera settings.
|
thx for putting in the time for this we need todo a bunch more before its reliable, we also need to solve the distance for the reduction system being wrong hmm |
This is a basic third person camera added to the BasisLocalCameraDriver.
When third-person is enabled, the camera follows the player and collides with world geometry on specified layers. I also added some InputActions to handle switching between first/third person state, and zooming the camera in and out. Zooming will affect the camera distance and the FOV. The camera distance is also affected by the local player scale.
The camera is updated on AfterSimulateOnLate to allow it to act as though it were detached from the player.
The code probably needs some cleanup before it can be integrated.
Issues and Todos: