From 3850fa007cb292585b6b70dd8edfb8f072574141 Mon Sep 17 00:00:00 2001 From: Gregory Labute Date: Tue, 11 Jun 2024 16:17:49 -0400 Subject: [PATCH] Improved character controller for jump state (#1008) --- .../3D Samples/ThirdPersonWithRoadieRun.unity | 36 ++- .../Model/CameronSimpleController.controller | 276 ++++++++++-------- 2 files changed, 183 insertions(+), 129 deletions(-) diff --git a/com.unity.cinemachine/Samples~/3D Samples/ThirdPersonWithRoadieRun.unity b/com.unity.cinemachine/Samples~/3D Samples/ThirdPersonWithRoadieRun.unity index 729f970ca..81e8dc952 100644 --- a/com.unity.cinemachine/Samples~/3D Samples/ThirdPersonWithRoadieRun.unity +++ b/com.unity.cinemachine/Samples~/3D Samples/ThirdPersonWithRoadieRun.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -1092,6 +1091,7 @@ MonoBehaviour: m_EditorClassIdentifier: ScanRecursively: 1 SuppressInputWhileBlending: 1 + IgnoreTimeScale: 0 m_ControllerManager: Controllers: - Name: CursorLock @@ -1102,6 +1102,7 @@ MonoBehaviour: Gain: 1 LegacyInput: Cancel LegacyGain: 1 + CancelDeltaTime: 0 InputValue: 0 Driver: AccelTime: 0 @@ -1426,7 +1427,6 @@ MonoBehaviour: m_EditorClassIdentifier: BulletPrefab: {fileID: 3056719325741855433, guid: 31d678dfd458ff84d95d644dd3730cca, type: 3} MaxBulletsPerSec: 6 - PlayerRotationTime: 0.2 Fire: Value: 0 Center: 0 @@ -2512,14 +2512,26 @@ PrefabInstance: propertyPath: m_ControllerManager.Controllers.Array.data[3].Input.LegacyInput value: Fire3 objectReference: {fileID: 0} + - target: {fileID: 7804758404662293724, guid: 4d8d7a9a98d3f4ac2967d48094ea010f, type: 3} + propertyPath: m_ControllerManager.Controllers.Array.data[4].Input.InputAction + value: + objectReference: {fileID: -1608118824973676762, guid: 1d6e640e716dc4ff6989b73d02023f2b, type: 3} - target: {fileID: 7804758404662293724, guid: 4d8d7a9a98d3f4ac2967d48094ea010f, type: 3} propertyPath: m_ControllerManager.Controllers.Array.data[4].Input.LegacyInput value: Mouse X objectReference: {fileID: 0} + - target: {fileID: 7804758404662293724, guid: 4d8d7a9a98d3f4ac2967d48094ea010f, type: 3} + propertyPath: m_ControllerManager.Controllers.Array.data[5].Input.InputAction + value: + objectReference: {fileID: -1608118824973676762, guid: 1d6e640e716dc4ff6989b73d02023f2b, type: 3} - target: {fileID: 7804758404662293724, guid: 4d8d7a9a98d3f4ac2967d48094ea010f, type: 3} propertyPath: m_ControllerManager.Controllers.Array.data[5].Input.LegacyInput value: Mouse Y objectReference: {fileID: 0} + - target: {fileID: 7804758404662293724, guid: 4d8d7a9a98d3f4ac2967d48094ea010f, type: 3} + propertyPath: m_ControllerManager.Controllers.Array.data[6].Input.InputAction + value: + objectReference: {fileID: -1608118824973676762, guid: 1d6e640e716dc4ff6989b73d02023f2b, type: 3} - target: {fileID: 7804758404662293724, guid: 4d8d7a9a98d3f4ac2967d48094ea010f, type: 3} propertyPath: m_ControllerManager.Controllers.Array.data[6].Input.LegacyInput value: Fire1 @@ -3082,7 +3094,7 @@ Transform: m_GameObject: {fileID: 2076565716644322336} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 1.559051, y: 0.77348024, z: -3.1799998} + m_LocalPosition: {x: 1.559051, y: 0.57348025, z: -3.1799998} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -3119,7 +3131,7 @@ MonoBehaviour: m_EditorClassIdentifier: Damping: {x: 0.1, y: 0.5, z: 0.3} ShoulderOffset: {x: 0.40905112, y: -0.41026962, z: 0} - VerticalArmLength: 0.3 + VerticalArmLength: 0.1 CameraSide: 1 CameraDistance: 3.8 AvoidObstacles: @@ -3191,19 +3203,17 @@ MonoBehaviour: Camera: {fileID: 334051334} ActivateAfter: 0 MinDuration: 0 - - FullHash: 1965258778 + - FullHash: -827840423 Camera: {fileID: 2076565716644322337} - ActivateAfter: 0.4 + ActivateAfter: 0.1 MinDuration: 0 - - FullHash: -203094115 + - FullHash: 1068812385 Camera: {fileID: 2076565716644322337} - ActivateAfter: 0.4 + ActivateAfter: 0.1 MinDuration: 0 HashOfParent: - Hash: 1432961145 HashOfParent: 756556552 - - Hash: -916648961 - HashOfParent: 756556552 - Hash: 81563449 HashOfParent: 756556552 - Hash: 1049899859 @@ -3212,9 +3222,7 @@ MonoBehaviour: HashOfParent: 81563449 - Hash: -1759641626 HashOfParent: 81563449 - - Hash: -1729575745 - HashOfParent: 756556552 - - Hash: -203094115 + - Hash: 788460410 HashOfParent: 756556552 - Hash: -827840423 HashOfParent: 756556552 @@ -3224,6 +3232,8 @@ MonoBehaviour: HashOfParent: -827840423 - Hash: -382662320 HashOfParent: -827840423 + - Hash: 1068812385 + HashOfParent: 756556552 m_LegacyLookAt: {fileID: 0} m_LegacyFollow: {fileID: 0} --- !u!4 &2076565717059590787 diff --git a/com.unity.cinemachine/Samples~/Shared Assets/Cameron/Model/CameronSimpleController.controller b/com.unity.cinemachine/Samples~/Shared Assets/Cameron/Model/CameronSimpleController.controller index ada6ce5a2..de449873a 100644 --- a/com.unity.cinemachine/Samples~/Shared Assets/Cameron/Model/CameronSimpleController.controller +++ b/com.unity.cinemachine/Samples~/Shared Assets/Cameron/Model/CameronSimpleController.controller @@ -7,11 +7,13 @@ AnimatorState: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Jump Walk + m_Name: Jump m_Speed: 0.8 m_CycleOffset: 0 m_Transitions: - {fileID: -400134937491866966} + - {fileID: -1707363395476518042} + - {fileID: 5449976492846864008} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -27,6 +29,34 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1101 &-4873801060735358018 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Jump + m_EventTreshold: 0 + - m_ConditionMode: 1 + m_ConditionEvent: Running + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 2335464205704306083} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.5522388 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &-3686201905407010574 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -124,6 +154,59 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &-1707363395476518042 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Land + m_EventTreshold: 0 + - m_ConditionMode: 1 + m_ConditionEvent: Running + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 8420703450221908322} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.5614035 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 +--- !u!1101 &-940346409258657620 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Land + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 8420703450221908322} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.5614035 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &-400134937491866966 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -135,6 +218,9 @@ AnimatorStateTransition: - m_ConditionMode: 1 m_ConditionEvent: Land m_EventTreshold: 0 + - m_ConditionMode: 1 + m_ConditionEvent: Walking + m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: -2151006468185585992} m_Solo: 0 @@ -163,49 +249,49 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: DirZ m_Type: 1 m_DefaultFloat: 1 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: MotionScale m_Type: 1 m_DefaultFloat: 1 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: JumpScale m_Type: 1 m_DefaultFloat: 1 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Jump m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Land m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Walking m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: Running m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -219,7 +305,7 @@ AnimatorController: m_IKPass: 0 m_SyncedLayerAffectsTiming: 0 m_Controller: {fileID: 9100000} ---- !u!1101 &775935384185778692 +--- !u!1101 &1490814412725467169 AnimatorStateTransition: m_ObjectHideFlags: 1 m_CorrespondingSourceObject: {fileID: 0} @@ -228,23 +314,23 @@ AnimatorStateTransition: m_Name: m_Conditions: - m_ConditionMode: 1 - m_ConditionEvent: Land + m_ConditionEvent: Running m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 5351786783861475141} + m_DstState: {fileID: 8420703450221908322} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 - m_TransitionDuration: 0.17518768 - m_TransitionOffset: 0.0001478458 - m_ExitTime: 0.5443275 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.68085104 m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 ---- !u!1101 &1490814412725467169 +--- !u!1101 &2072700335257187397 AnimatorStateTransition: m_ObjectHideFlags: 1 m_CorrespondingSourceObject: {fileID: 0} @@ -253,22 +339,55 @@ AnimatorStateTransition: m_Name: m_Conditions: - m_ConditionMode: 1 + m_ConditionEvent: Jump + m_EventTreshold: 0 + - m_ConditionMode: 1 + m_ConditionEvent: Walking + m_EventTreshold: 0 + - m_ConditionMode: 2 m_ConditionEvent: Running m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 8420703450221908322} + m_DstState: {fileID: -7061757097289198402} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.68085104 + m_ExitTime: 0.5522388 m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1102 &2335464205704306083 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Running Jump + m_Speed: 0.8 + m_CycleOffset: 0 + m_Transitions: + - {fileID: -940346409258657620} + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 1 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 1827226128182048838, guid: 0c6f7469db3db6d4ba890e20f1f0d353, type: 3} + m_Tag: + m_SpeedParameter: JumpScale + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1101 &3070331966817909641 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -344,31 +463,6 @@ BlendTree: m_UseAutomaticThresholds: 1 m_NormalizedBlendValues: 0 m_BlendType: 2 ---- !u!1101 &3691152097968358944 -AnimatorStateTransition: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: - m_Conditions: - - m_ConditionMode: 1 - m_ConditionEvent: Land - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 8420703450221908322} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0.06615287 - m_TransitionOffset: 0.54 - m_ExitTime: 0.58234453 - m_HasExitTime: 0 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 --- !u!206 &3712578732204055543 BlendTree: m_ObjectHideFlags: 1 @@ -441,60 +535,6 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 ---- !u!1102 &3847384438597556834 -AnimatorState: - serializedVersion: 6 - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Jump Idle - m_Speed: 0.8 - m_CycleOffset: 0 - m_Transitions: - - {fileID: 775935384185778692} - m_StateMachineBehaviours: [] - m_Position: {x: 50, y: 50, z: 0} - m_IKOnFeet: 0 - m_WriteDefaultValues: 1 - m_Mirror: 0 - m_SpeedParameterActive: 1 - m_MirrorParameterActive: 0 - m_CycleOffsetParameterActive: 0 - m_TimeParameterActive: 0 - m_Motion: {fileID: 1827226128182048838, guid: 0c6f7469db3db6d4ba890e20f1f0d353, type: 3} - m_Tag: - m_SpeedParameter: JumpScale - m_MirrorParameter: - m_CycleOffsetParameter: - m_TimeParameter: ---- !u!1102 &4380426822070008261 -AnimatorState: - serializedVersion: 6 - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Jump Run - m_Speed: 0.8 - m_CycleOffset: 0.79 - m_Transitions: - - {fileID: 3691152097968358944} - m_StateMachineBehaviours: [] - m_Position: {x: 50, y: 50, z: 0} - m_IKOnFeet: 0 - m_WriteDefaultValues: 1 - m_Mirror: 0 - m_SpeedParameterActive: 1 - m_MirrorParameterActive: 0 - m_CycleOffsetParameterActive: 0 - m_TimeParameterActive: 0 - m_Motion: {fileID: 1827226128182048838, guid: 0c6f7469db3db6d4ba890e20f1f0d353, type: 3} - m_Tag: - m_SpeedParameter: JumpScale - m_MirrorParameter: - m_CycleOffsetParameter: - m_TimeParameter: --- !u!1107 &5252751724755048829 AnimatorStateMachine: serializedVersion: 6 @@ -507,21 +547,18 @@ AnimatorStateMachine: - serializedVersion: 1 m_State: {fileID: 5351786783861475141} m_Position: {x: 70, y: 230, z: 0} - - serializedVersion: 1 - m_State: {fileID: 3847384438597556834} - m_Position: {x: 490, y: 230, z: 0} - serializedVersion: 1 m_State: {fileID: -2151006468185585992} - m_Position: {x: 220, y: 310, z: 0} + m_Position: {x: 400, y: 230, z: 0} - serializedVersion: 1 m_State: {fileID: -7061757097289198402} - m_Position: {x: 490, y: 310, z: 0} - - serializedVersion: 1 - m_State: {fileID: 4380426822070008261} - m_Position: {x: 490, y: 390, z: 0} + m_Position: {x: 480, y: 330, z: 0} - serializedVersion: 1 m_State: {fileID: 8420703450221908322} m_Position: {x: 70, y: 390, z: 0} + - serializedVersion: 1 + m_State: {fileID: 2335464205704306083} + m_Position: {x: 410, y: 430, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] @@ -543,9 +580,9 @@ AnimatorState: m_Speed: 0.2 m_CycleOffset: 0 m_Transitions: - - {fileID: 5406036619693422872} - {fileID: -2087256297465246186} - {fileID: 9102725391783152931} + - {fileID: 5408550826215924127} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -561,7 +598,7 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &5406036619693422872 +--- !u!1101 &5408550826215924127 AnimatorStateTransition: m_ObjectHideFlags: 1 m_CorrespondingSourceObject: {fileID: 0} @@ -573,20 +610,20 @@ AnimatorStateTransition: m_ConditionEvent: Jump m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 3847384438597556834} + m_DstState: {fileID: -7061757097289198402} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 - m_TransitionDuration: 0.099303246 + m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.73747194 + m_ExitTime: 0.9 m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 ---- !u!1101 &5969063405154933277 +--- !u!1101 &5449976492846864008 AnimatorStateTransition: m_ObjectHideFlags: 1 m_CorrespondingSourceObject: {fileID: 0} @@ -595,17 +632,23 @@ AnimatorStateTransition: m_Name: m_Conditions: - m_ConditionMode: 1 - m_ConditionEvent: Jump + m_ConditionEvent: Land + m_EventTreshold: 0 + - m_ConditionMode: 2 + m_ConditionEvent: Walking + m_EventTreshold: 0 + - m_ConditionMode: 2 + m_ConditionEvent: Running m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 4380426822070008261} + m_DstState: {fileID: 5351786783861475141} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 - m_TransitionDuration: 0.099303246 + m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.73747194 + m_ExitTime: 0.5614035 m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 @@ -650,9 +693,10 @@ AnimatorState: m_Speed: 1 m_CycleOffset: 0 m_Transitions: - - {fileID: 5969063405154933277} - {fileID: 3070331966817909641} - {fileID: 6577597960447181989} + - {fileID: 2072700335257187397} + - {fileID: -4873801060735358018} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0