From 908e78ed4b3cfac4bd89628bd0b27134cac1d0d0 Mon Sep 17 00:00:00 2001 From: Spencer Date: Sun, 18 Apr 2021 18:42:48 -0500 Subject: [PATCH] Working on Jump Animation (in progress) --- .../Animations/Protagonist Jump Land v1.anim | 36 ++------- .../Protagonist Jump Midair v1.anim | 74 ------------------- .../Protagonist Jump Takeoff v1.anim.meta | 8 -- ...keoff v1.anim => Protagonist Jump v1.anim} | 10 ++- ...nim.meta => Protagonist Jump v1.anim.meta} | 2 +- .../Protagonist Run Cycle.controller | 47 ++++++++++-- MuseumGame/Assets/Scripts/movement.cs | 17 +++++ 7 files changed, 71 insertions(+), 123 deletions(-) delete mode 100644 MuseumGame/Assets/Animations/Protagonist Jump Midair v1.anim delete mode 100644 MuseumGame/Assets/Animations/Protagonist Jump Takeoff v1.anim.meta rename MuseumGame/Assets/Animations/{Protagonist Jump Takeoff v1.anim => Protagonist Jump v1.anim} (83%) rename MuseumGame/Assets/Animations/{Protagonist Jump Midair v1.anim.meta => Protagonist Jump v1.anim.meta} (79%) diff --git a/MuseumGame/Assets/Animations/Protagonist Jump Land v1.anim b/MuseumGame/Assets/Animations/Protagonist Jump Land v1.anim index 411fab2..684acef 100644 --- a/MuseumGame/Assets/Animations/Protagonist Jump Land v1.anim +++ b/MuseumGame/Assets/Animations/Protagonist Jump Land v1.anim @@ -6,7 +6,7 @@ AnimationClip: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Protagonist Jump Land v1 + m_Name: serializedVersion: 6 m_Legacy: 0 m_Compressed: 0 @@ -17,45 +17,21 @@ AnimationClip: m_PositionCurves: [] m_ScaleCurves: [] m_FloatCurves: [] - m_PPtrCurves: - - curve: - - time: 0 - value: {fileID: 1540433061672771331, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - time: 0.083333336 - value: {fileID: -5324470790269307012, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - time: 0.16666667 - value: {fileID: -3023117061024659501, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - time: 0.25 - value: {fileID: 5481875011490478117, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - attribute: m_Sprite - path: - classID: 212 - script: {fileID: 0} - m_SampleRate: 12 + m_PPtrCurves: [] + m_SampleRate: 60 m_WrapMode: 0 m_Bounds: m_Center: {x: 0, y: 0, z: 0} m_Extent: {x: 0, y: 0, z: 0} m_ClipBindingConstant: - genericBindings: - - serializedVersion: 2 - path: 0 - attribute: 0 - script: {fileID: 0} - typeID: 212 - customType: 23 - isPPtrCurve: 1 - pptrCurveMapping: - - {fileID: 1540433061672771331, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - {fileID: -5324470790269307012, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - {fileID: -3023117061024659501, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - {fileID: 5481875011490478117, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} + genericBindings: [] + pptrCurveMapping: [] m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 0.33333334 + m_StopTime: 1 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 diff --git a/MuseumGame/Assets/Animations/Protagonist Jump Midair v1.anim b/MuseumGame/Assets/Animations/Protagonist Jump Midair v1.anim deleted file mode 100644 index 4c2b828..0000000 --- a/MuseumGame/Assets/Animations/Protagonist Jump Midair v1.anim +++ /dev/null @@ -1,74 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!74 &7400000 -AnimationClip: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Protagonist Jump Midair v1 - serializedVersion: 6 - m_Legacy: 0 - m_Compressed: 0 - m_UseHighQualityCurve: 1 - m_RotationCurves: [] - m_CompressedRotationCurves: [] - m_EulerCurves: [] - m_PositionCurves: [] - m_ScaleCurves: [] - m_FloatCurves: [] - m_PPtrCurves: - - curve: - - time: 0 - value: {fileID: -472527136499386539, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - time: 0.083333336 - value: {fileID: 8667279835780202195, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - time: 0.16666667 - value: {fileID: -1355301765853423626, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - attribute: m_Sprite - path: - classID: 212 - script: {fileID: 0} - m_SampleRate: 12 - m_WrapMode: 0 - m_Bounds: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 0, y: 0, z: 0} - m_ClipBindingConstant: - genericBindings: - - serializedVersion: 2 - path: 0 - attribute: 0 - script: {fileID: 0} - typeID: 212 - customType: 23 - isPPtrCurve: 1 - pptrCurveMapping: - - {fileID: -472527136499386539, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - {fileID: 8667279835780202195, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - - {fileID: -1355301765853423626, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - m_AnimationClipSettings: - serializedVersion: 2 - m_AdditiveReferencePoseClip: {fileID: 0} - m_AdditiveReferencePoseTime: 0 - m_StartTime: 0 - m_StopTime: 0.25 - m_OrientationOffsetY: 0 - m_Level: 0 - m_CycleOffset: 0 - m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 - m_LoopBlend: 0 - m_LoopBlendOrientation: 0 - m_LoopBlendPositionY: 0 - m_LoopBlendPositionXZ: 0 - m_KeepOriginalOrientation: 0 - m_KeepOriginalPositionY: 1 - m_KeepOriginalPositionXZ: 0 - m_HeightFromFeet: 0 - m_Mirror: 0 - m_EditorCurves: [] - m_EulerEditorCurves: [] - m_HasGenericRootTransform: 0 - m_HasMotionFloatCurves: 0 - m_Events: [] diff --git a/MuseumGame/Assets/Animations/Protagonist Jump Takeoff v1.anim.meta b/MuseumGame/Assets/Animations/Protagonist Jump Takeoff v1.anim.meta deleted file mode 100644 index d4d926f..0000000 --- a/MuseumGame/Assets/Animations/Protagonist Jump Takeoff v1.anim.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7017e4bf141d99e4e80e0efcc98e51fa -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 7400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/MuseumGame/Assets/Animations/Protagonist Jump Takeoff v1.anim b/MuseumGame/Assets/Animations/Protagonist Jump v1.anim similarity index 83% rename from MuseumGame/Assets/Animations/Protagonist Jump Takeoff v1.anim rename to MuseumGame/Assets/Animations/Protagonist Jump v1.anim index 9055954..62bf66f 100644 --- a/MuseumGame/Assets/Animations/Protagonist Jump Takeoff v1.anim +++ b/MuseumGame/Assets/Animations/Protagonist Jump v1.anim @@ -6,7 +6,7 @@ AnimationClip: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Protagonist Jump Takeoff v1 + m_Name: Protagonist Jump v1 serializedVersion: 6 m_Legacy: 0 m_Compressed: 0 @@ -27,6 +27,10 @@ AnimationClip: value: {fileID: -1442490000430059858, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - time: 0.25 value: {fileID: -7868241686654605716, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} + - time: 0.33333334 + value: {fileID: -472527136499386539, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} + - time: 0.41666666 + value: {fileID: 8667279835780202195, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} attribute: m_Sprite path: classID: 212 @@ -50,12 +54,14 @@ AnimationClip: - {fileID: 429644503569667005, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - {fileID: -1442490000430059858, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} - {fileID: -7868241686654605716, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} + - {fileID: -472527136499386539, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} + - {fileID: 8667279835780202195, guid: c8e2cf18de8fd7742b48c17d509d358c, type: 3} m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 0.33333334 + m_StopTime: 0.5 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 diff --git a/MuseumGame/Assets/Animations/Protagonist Jump Midair v1.anim.meta b/MuseumGame/Assets/Animations/Protagonist Jump v1.anim.meta similarity index 79% rename from MuseumGame/Assets/Animations/Protagonist Jump Midair v1.anim.meta rename to MuseumGame/Assets/Animations/Protagonist Jump v1.anim.meta index 1c63e9b..a5a8d4b 100644 --- a/MuseumGame/Assets/Animations/Protagonist Jump Midair v1.anim.meta +++ b/MuseumGame/Assets/Animations/Protagonist Jump v1.anim.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 11654141f921fec419f6b14b1fc80a29 +guid: 56c62be1789ab084f90a106333e715dd NativeFormatImporter: externalObjects: {} mainObjectFileID: 7400000 diff --git a/MuseumGame/Assets/Animations/Protagonist Run Cycle.controller b/MuseumGame/Assets/Animations/Protagonist Run Cycle.controller index 5768d16..66065e7 100644 --- a/MuseumGame/Assets/Animations/Protagonist Run Cycle.controller +++ b/MuseumGame/Assets/Animations/Protagonist Run Cycle.controller @@ -73,11 +73,11 @@ AnimatorState: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Takeoff + m_Name: Jump m_Speed: 1 m_CycleOffset: 0 m_Transitions: - - {fileID: -8501373588511834804} + - {fileID: -3874732199687805077} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -115,6 +115,28 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &-3874732199687805077 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: [] + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 3480931448333261977} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.25 + m_HasExitTime: 1 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1107 &-121783143131200048 AnimatorStateMachine: serializedVersion: 6 @@ -132,13 +154,10 @@ AnimatorStateMachine: m_Position: {x: 80, y: 160, z: 0} - serializedVersion: 1 m_State: {fileID: -7548201986605107798} - m_Position: {x: 420, y: 200, z: 0} - - serializedVersion: 1 - m_State: {fileID: 8064295483439524213} - m_Position: {x: 420, y: 110, z: 0} + m_Position: {x: 350, y: 160, z: 0} - serializedVersion: 1 m_State: {fileID: 3480931448333261977} - m_Position: {x: 420, y: 30, z: 0} + m_Position: {x: 350, y: 70, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] @@ -163,7 +182,19 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} + - m_Name: velocityY + m_Type: 1 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} + - m_Name: isGrounded + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer diff --git a/MuseumGame/Assets/Scripts/movement.cs b/MuseumGame/Assets/Scripts/movement.cs index ac4a17e..d05776c 100644 --- a/MuseumGame/Assets/Scripts/movement.cs +++ b/MuseumGame/Assets/Scripts/movement.cs @@ -18,6 +18,7 @@ public class movement : MonoBehaviour public float _MinAcc = -1.0f; public float _Deceleration = 2f; public float jumpForce = 350; + private bool isGrounded; // Start is called before the first frame update void Start() @@ -37,6 +38,7 @@ public class movement : MonoBehaviour horizontal = Input.GetAxisRaw("Horizontal"); vertical = Input.GetAxisRaw("Vertical"); animator.SetFloat("horizontal", horizontal); + if (horizontal < 0) { @@ -73,6 +75,7 @@ public class movement : MonoBehaviour rb2d.AddForce(new Vector2(0, jumpForce)); jumping = true; } + JumpAnimation(); } private void acceleration() @@ -119,4 +122,18 @@ public class movement : MonoBehaviour { jumping = false; } + + private void JumpAnimation() + { + if (!isGrounded) + { + animator.SetBool("isGrounded", false); + animator.SetFloat("velocityY", 1 * Mathf.Sign(rb2d.velocity.y)); + } + if (isGrounded) + { + animator.SetBool("isGrounded", true); + animator.SetFloat("velocityY", 0); + } + } }