From a98e003edc359fff0a2e93310d0e5ff20f746ff5 Mon Sep 17 00:00:00 2001 From: isaacwarholpond Date: Fri, 21 Nov 2025 00:04:37 -0800 Subject: [PATCH] fixed gravity + jumping --- Assets/Materials/leaf.mat | 3 +- Assets/Materials/trunk.mat | 3 +- Assets/Scripts/PlayerMovement.cs | 59 ++++++++++++++++-------------- Packages/manifest.json | 4 +- Packages/packages-lock.json | 18 ++++----- ProjectSettings/ProjectVersion.txt | 4 +- 6 files changed, 47 insertions(+), 44 deletions(-) diff --git a/Assets/Materials/leaf.mat b/Assets/Materials/leaf.mat index ab1d39e..7e8c3b7 100644 --- a/Assets/Materials/leaf.mat +++ b/Assets/Materials/leaf.mat @@ -20,8 +20,7 @@ Material: m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 stringTagMap: {} - disabledShaderPasses: - - MOTIONVECTORS + disabledShaderPasses: [] m_LockedProperties: m_SavedProperties: serializedVersion: 3 diff --git a/Assets/Materials/trunk.mat b/Assets/Materials/trunk.mat index aec35c9..ba3e0e4 100644 --- a/Assets/Materials/trunk.mat +++ b/Assets/Materials/trunk.mat @@ -20,8 +20,7 @@ Material: m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 stringTagMap: {} - disabledShaderPasses: - - MOTIONVECTORS + disabledShaderPasses: [] m_LockedProperties: m_SavedProperties: serializedVersion: 3 diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index fa23a43..cdeb3d4 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -187,6 +187,26 @@ public class PlayerMovement : MonoBehaviour + + if (controller.isGrounded && velocity.y < 0) + { + velocity.y = -0.5f; + + } + //else if (controller.isGrounded && !jumpAction.WasPerformedThisFrame()) + //{ + // velocity.y = 0; + //} + if (jumpAction.WasPerformedThisFrame() && controller.isGrounded) + { + //Debug.Log("jumped"); + //velocity.y = Mathf.Sqrt(jumpHeight * -1f * gravity); + } + + velocity.y += gravity * Time.deltaTime; + + Debug.Log(controller.isGrounded); + if (canWalk /*&& !running*/) { Vector3 move = new Vector3(moveInput.x * speed, 0, moveInput.y * speed); @@ -200,21 +220,6 @@ public class PlayerMovement : MonoBehaviour // controller.Move(move2 * Time.deltaTime); //} controller.Move(velocity * Time.deltaTime); - if (!controller.isGrounded && !jumpAction.WasPerformedThisFrame()) - { - velocity.y += gravity * Time.deltaTime; - } - else if (controller.isGrounded && !jumpAction.WasPerformedThisFrame()) - { - velocity.y = 0; - } - else if (jumpAction.WasPerformedThisFrame() && controller.isGrounded) - { - Debug.Log("jumped"); - velocity.y = Mathf.Sqrt(jumpHeight * -1f * gravity); - } - - Debug.Log(controller.isGrounded); } public void PauseGame(InputAction.CallbackContext context) { @@ -290,18 +295,18 @@ public class PlayerMovement : MonoBehaviour dashDistanceTimer = 0; } } - //public void OnJump(InputAction.CallbackContext context) - //{ - // if (context.performed && controller.isGrounded) - // { - // velocity.y = Mathf.Sqrt(jumpHeight * -1f * gravity); - // jumped = true; - // } - // if (context.canceled && !controller.isGrounded) - // { - // jumped = false; - // } - //} + public void OnJump(InputAction.CallbackContext context) + { + if (context.performed && controller.isGrounded) + { + velocity.y = Mathf.Sqrt(jumpHeight * -1f * gravity); + jumped = true; + } + if (context.canceled && !controller.isGrounded) + { + jumped = false; + } + } private void MyInput() { diff --git a/Packages/manifest.json b/Packages/manifest.json index cb49a34..a22efbc 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -3,9 +3,9 @@ "com.unity.2d.aseprite": "2.0.2", "com.unity.ai.navigation": "2.0.9", "com.unity.cinemachine": "3.1.4", - "com.unity.collab-proxy": "2.9.3", + "com.unity.collab-proxy": "2.10.2", "com.unity.ide.rider": "3.0.38", - "com.unity.ide.visualstudio": "2.0.23", + "com.unity.ide.visualstudio": "2.0.25", "com.unity.inputsystem": "1.14.2", "com.unity.multiplayer.center": "1.0.0", "com.unity.postprocessing": "3.5.1", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 6e8d7a8..ab8d5af 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -51,7 +51,7 @@ "url": "https://packages.unity.com" }, "com.unity.burst": { - "version": "1.8.24", + "version": "1.8.25", "depth": 2, "source": "registry", "dependencies": { @@ -71,18 +71,18 @@ "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "2.9.3", + "version": "2.10.2", "depth": 0, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.collections": { - "version": "2.5.7", + "version": "2.6.2", "depth": 2, "source": "registry", "dependencies": { - "com.unity.burst": "1.8.19", + "com.unity.burst": "1.8.23", "com.unity.mathematics": "1.3.2", "com.unity.test-framework": "1.4.6", "com.unity.nuget.mono-cecil": "1.11.5", @@ -106,11 +106,11 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.23", + "version": "2.0.25", "depth": 0, "source": "registry", "dependencies": { - "com.unity.test-framework": "1.1.9" + "com.unity.test-framework": "1.1.31" }, "url": "https://packages.unity.com" }, @@ -233,7 +233,7 @@ } }, "com.unity.splines": { - "version": "2.8.1", + "version": "2.8.2", "depth": 1, "source": "registry", "dependencies": { @@ -244,7 +244,7 @@ "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.5.1", + "version": "1.6.0", "depth": 0, "source": "builtin", "dependencies": { @@ -254,7 +254,7 @@ } }, "com.unity.test-framework.performance": { - "version": "3.1.0", + "version": "3.2.0", "depth": 3, "source": "registry", "dependencies": { diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 8bd173d..48c0834 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 6000.2.1f1 -m_EditorVersionWithRevision: 6000.2.1f1 (55300504c302) +m_EditorVersion: 6000.2.13f1 +m_EditorVersionWithRevision: 6000.2.13f1 (abdb44fca7f7)