fixed gravity + jumping

This commit is contained in:
2025-11-21 00:04:37 -08:00
parent bc5cf80f30
commit a98e003edc
6 changed files with 47 additions and 44 deletions

View File

@@ -20,8 +20,7 @@ Material:
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3

View File

@@ -20,8 +20,7 @@ Material:
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3

View File

@@ -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()
{

View File

@@ -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",

View File

@@ -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": {

View File

@@ -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)