From 711b02571a99aa27da9464119e9a3665339e3e64 Mon Sep 17 00:00:00 2001 From: Jenny <jen333jjou@icloud.com> Date: Fri, 16 Apr 2021 06:18:47 +0100 Subject: [PATCH] changed animations made jump loop and made glide animation work --- Assets/Animations/Jumping Up.fbx.meta | 2 +- Assets/Animations/Walk&Run Movement.controller | 18 ++++++++++++------ Assets/Scenes/Game/SampleScene.unity | 2 +- Assets/Scripts/PlayerPickUp.cs | 1 + Assets/Scripts/SCTPSController.cs | 14 +++++++++++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Assets/Animations/Jumping Up.fbx.meta b/Assets/Animations/Jumping Up.fbx.meta index 5b38264..6fc3e8a 100644 --- a/Assets/Animations/Jumping Up.fbx.meta +++ b/Assets/Animations/Jumping Up.fbx.meta @@ -46,7 +46,7 @@ ModelImporter: cycleOffset: 0 loop: 0 hasAdditiveReferencePose: 0 - loopTime: 0 + loopTime: 1 loopBlend: 0 loopBlendOrientation: 0 loopBlendPositionY: 0 diff --git a/Assets/Animations/Walk&Run Movement.controller b/Assets/Animations/Walk&Run Movement.controller index c206d63..681fd14 100644 --- a/Assets/Animations/Walk&Run Movement.controller +++ b/Assets/Animations/Walk&Run Movement.controller @@ -174,25 +174,31 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Jump m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: AnimSpeed m_Type: 1 m_DefaultFloat: 1 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: PickUp m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} + - m_Name: Motion + m_Type: 1 + m_DefaultFloat: 2 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -360,8 +366,8 @@ AnimatorState: type: 3} m_Tag: m_SpeedParameter: AnimSpeed - m_MirrorParameter: - m_CycleOffsetParameter: Speed + m_MirrorParameter: Jump + m_CycleOffsetParameter: Motion m_TimeParameter: Speed --- !u!1101 &6964413758257151049 AnimatorStateTransition: diff --git a/Assets/Scenes/Game/SampleScene.unity b/Assets/Scenes/Game/SampleScene.unity index a9f8e46..6442626 100644 --- a/Assets/Scenes/Game/SampleScene.unity +++ b/Assets/Scenes/Game/SampleScene.unity @@ -9599,7 +9599,7 @@ PrefabInstance: - target: {fileID: 1331997591070191852, guid: 2342577add2bab844a55e25cc4fea601, type: 3} propertyPath: pushPower - value: 2 + value: 1 objectReference: {fileID: 0} - target: {fileID: 1331997591070191852, guid: 2342577add2bab844a55e25cc4fea601, type: 3} diff --git a/Assets/Scripts/PlayerPickUp.cs b/Assets/Scripts/PlayerPickUp.cs index ac83a2c..3a398e4 100644 --- a/Assets/Scripts/PlayerPickUp.cs +++ b/Assets/Scripts/PlayerPickUp.cs @@ -122,6 +122,7 @@ public class PlayerPickUp : MonoBehaviour if (interactiveobjects.Contains(other.gameObject)) { interactiveobjects.Remove(other.gameObject); + anim.SetBool("PickUp", false); } } diff --git a/Assets/Scripts/SCTPSController.cs b/Assets/Scripts/SCTPSController.cs index 858cafb..084cd7b 100644 --- a/Assets/Scripts/SCTPSController.cs +++ b/Assets/Scripts/SCTPSController.cs @@ -64,6 +64,7 @@ public class SCTPSController : MonoBehaviour public bool running; public float jumpLength; + public bool gliding; void Start() { @@ -195,10 +196,14 @@ public class SCTPSController : MonoBehaviour onGround = false; } - if (Input.GetButton("Jump")) + if (!gliding && Input.GetButton("Jump")) { jumpLength += 1f; } + else if (gliding == true) + { + jumpLength = 0; + } if (jumpLength > 0) { @@ -220,18 +225,21 @@ public class SCTPSController : MonoBehaviour if (!characterController.isGrounded && Input.GetKey(KeyCode.LeftShift)) { + gliding = true; + + Glide(); + gravity = 10f; glidesDone++; moveDirection.x = Input.GetAxis("Horizontal") * glideSpeed; moveDirection.z = Input.GetAxis("Vertical") * glideSpeed; moveDirection = transform.TransformDirection(moveDirection); - - Glide(); } else { gravity = 30f; + gliding = false; } if (glidesDone >= 10) -- GitLab