improve camera controls

This commit is contained in:
Cat Flynn 2021-04-15 19:32:09 +01:00
parent e7e4bbde07
commit 5cdd4e376f
6 changed files with 267 additions and 9 deletions

View File

@ -610,6 +610,7 @@ GameObject:
- component: {fileID: 5661344207789115423} - component: {fileID: 5661344207789115423}
- component: {fileID: 7951179702612018041} - component: {fileID: 7951179702612018041}
- component: {fileID: 4646968772435671935} - component: {fileID: 4646968772435671935}
- component: {fileID: 6450882301115788249}
m_Layer: 0 m_Layer: 0
m_Name: CM_ThirdPerson m_Name: CM_ThirdPerson
m_TagString: Untagged m_TagString: Untagged
@ -718,7 +719,7 @@ MonoBehaviour:
m_RecenterToTargetHeading: m_RecenterToTargetHeading:
m_enabled: 0 m_enabled: 0
m_WaitTime: 1 m_WaitTime: 1
m_RecenteringTime: 2 m_RecenteringTime: 1.1
m_LegacyHeadingDefinition: -1 m_LegacyHeadingDefinition: -1
m_LegacyVelocityFilterStrength: -1 m_LegacyVelocityFilterStrength: -1
m_BindingMode: 4 m_BindingMode: 4
@ -727,9 +728,9 @@ MonoBehaviour:
- m_Height: 2 - m_Height: 2
m_Radius: 2 m_Radius: 2
- m_Height: 1 - m_Height: 1
m_Radius: 1.5 m_Radius: 2
- m_Height: 0 - m_Height: 0
m_Radius: 1.5 m_Radius: 2
m_LegacyHeadingBias: 3.4028235e+38 m_LegacyHeadingBias: 3.4028235e+38
m_Rigs: m_Rigs:
- {fileID: 5661344207439169722} - {fileID: 5661344207439169722}
@ -836,6 +837,21 @@ MonoBehaviour:
m_StringArgument: m_StringArgument:
m_BoolArgument: 0 m_BoolArgument: 0
m_CallState: 2 m_CallState: 2
--- !u!114 &6450882301115788249
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5661344207789115490}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c825c87a182e76448880f374c3ef9b73, type: 3}
m_Name:
m_EditorClassIdentifier:
_axisDifference: 0.3
_inputMagnitude: 0.1
_moveInput: {fileID: -470994912084233759, guid: d4d9eb5db7beac84ca3cb36cfc09cd0a, type: 3}
--- !u!1 &5661344207849762654 --- !u!1 &5661344207849762654
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -607,7 +607,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1703779518772407877} m_GameObject: {fileID: 1703779518772407877}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.036, y: 1.403, z: -0.093} m_LocalPosition: {x: 0, y: 1.403, z: 0}
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
m_Children: [] m_Children: []
m_Father: {fileID: 13726837642651460} m_Father: {fileID: 13726837642651460}

View File

@ -206,15 +206,11 @@ PrefabInstance:
- target: {fileID: 5661344207789115489, guid: dfbecbd9a563dba43be2d6139d9b3f90, type: 3} - target: {fileID: 5661344207789115489, guid: dfbecbd9a563dba43be2d6139d9b3f90, type: 3}
propertyPath: m_Follow propertyPath: m_Follow
value: value:
objectReference: {fileID: 4676633831945762709} objectReference: {fileID: 3150647428828152554}
- target: {fileID: 5661344207789115489, guid: dfbecbd9a563dba43be2d6139d9b3f90, type: 3} - target: {fileID: 5661344207789115489, guid: dfbecbd9a563dba43be2d6139d9b3f90, type: 3}
propertyPath: m_LookAt propertyPath: m_LookAt
value: value:
objectReference: {fileID: 3150647428828152554} objectReference: {fileID: 3150647428828152554}
- target: {fileID: 5661344207789115489, guid: dfbecbd9a563dba43be2d6139d9b3f90, type: 3}
propertyPath: m_XAxis.Value
value: -89.63728
objectReference: {fileID: 0}
- target: {fileID: 5661344207849762652, guid: dfbecbd9a563dba43be2d6139d9b3f90, type: 3} - target: {fileID: 5661344207849762652, guid: dfbecbd9a563dba43be2d6139d9b3f90, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 0 value: 0

View File

@ -2314,6 +2314,62 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.w
value: 0.56752455
objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.x
value: 0.06285194
objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y
value: 0.7702346
objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z
value: -0.28408483
objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.y
value: 0.25224686
objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.z
value: -2.720001
objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.w
value: 0.9724168
objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.x
value: 0.2295565
objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y
value: 0.040237267
objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z
value: -0.009498731
objectReference: {fileID: 0}
- target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: PlayerObjects value: PlayerObjects
@ -2362,6 +2418,154 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832548214813, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_BindingMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4676633832548214813, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_XAxis.Value
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832548214813, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Heading.m_Definition
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4676633832548214813, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Heading.m_VelocityFilterStrength
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4676633832617577688, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_BiasY
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832617577688, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_SoftZoneHeight
value: 0.55
objectReference: {fileID: 0}
- target: {fileID: 4676633832617577689, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_BindingMode
value: 4
objectReference: {fileID: 0}
- target: {fileID: 4676633832617577689, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_XAxis.Value
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832617577689, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Heading.m_Definition
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4676633832617577689, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Heading.m_VelocityFilterStrength
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.w
value: 0.56752455
objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.x
value: 0.06285194
objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y
value: 0.7702346
objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z
value: -0.28408483
objectReference: {fileID: 0}
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_YAxis.m_SpeedMode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_YAxis.m_InvertInput
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Heading.m_VelocityFilterStrength
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4676633832858914731, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832858914731, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.y
value: 0.25224686
objectReference: {fileID: 0}
- target: {fileID: 4676633832858914731, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.z
value: -2.720001
objectReference: {fileID: 0}
- target: {fileID: 4676633832858914773, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.w
value: 0.5333047
objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.x
value: 0.059062183
objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y
value: 0.7917243
objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z
value: -0.29201087
objectReference: {fileID: 0}
- target: {fileID: 4676633833077728949, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_SoftZoneHeight
value: 0.48
objectReference: {fileID: 0}
- target: {fileID: 4676633833077728950, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_BindingMode
value: 4
objectReference: {fileID: 0}
- target: {fileID: 4676633833077728950, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_XAxis.Value
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4676633833077728950, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_FollowOffset.z
value: -2
objectReference: {fileID: 0}
- target: {fileID: 4676633833077728950, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Heading.m_Definition
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4676633833077728950, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Heading.m_VelocityFilterStrength
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
--- !u!4 &783507384 stripped --- !u!4 &783507384 stripped

View File

@ -0,0 +1,31 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(CinemachineFreeLook))]
public class TargetRecentering : MonoBehaviour
{
[SerializeField] [Range(0, 1)] private float _inputMagnitude = 0.1f;
[SerializeField] private InputActionReference _moveInput;
private CinemachineFreeLook _freeLook;
private void Start()
{
_freeLook = GetComponent<CinemachineFreeLook>();
}
private void Update()
{
// if there is any horizontal movement input...
var input = _moveInput.action.ReadValue<Vector2>();
var result = Mathf.Abs(input.x) > Mathf.Abs(input.y) && input.magnitude > _inputMagnitude;
// ...enable target recentering in order to turn the camera with the player
_freeLook.m_RecenterToTargetHeading.m_enabled = result;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c825c87a182e76448880f374c3ef9b73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: