fixed gravity + jumping
This commit is contained in:
@@ -20,8 +20,7 @@ Material:
|
|||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: -1
|
||||||
stringTagMap: {}
|
stringTagMap: {}
|
||||||
disabledShaderPasses:
|
disabledShaderPasses: []
|
||||||
- MOTIONVECTORS
|
|
||||||
m_LockedProperties:
|
m_LockedProperties:
|
||||||
m_SavedProperties:
|
m_SavedProperties:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ Material:
|
|||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: -1
|
||||||
stringTagMap: {}
|
stringTagMap: {}
|
||||||
disabledShaderPasses:
|
disabledShaderPasses: []
|
||||||
- MOTIONVECTORS
|
|
||||||
m_LockedProperties:
|
m_LockedProperties:
|
||||||
m_SavedProperties:
|
m_SavedProperties:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
|
|||||||
@@ -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*/)
|
if (canWalk /*&& !running*/)
|
||||||
{
|
{
|
||||||
Vector3 move = new Vector3(moveInput.x * speed, 0, moveInput.y * speed);
|
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(move2 * Time.deltaTime);
|
||||||
//}
|
//}
|
||||||
controller.Move(velocity * 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)
|
public void PauseGame(InputAction.CallbackContext context)
|
||||||
{
|
{
|
||||||
@@ -290,18 +295,18 @@ public class PlayerMovement : MonoBehaviour
|
|||||||
dashDistanceTimer = 0;
|
dashDistanceTimer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//public void OnJump(InputAction.CallbackContext context)
|
public void OnJump(InputAction.CallbackContext context)
|
||||||
//{
|
{
|
||||||
// if (context.performed && controller.isGrounded)
|
if (context.performed && controller.isGrounded)
|
||||||
// {
|
{
|
||||||
// velocity.y = Mathf.Sqrt(jumpHeight * -1f * gravity);
|
velocity.y = Mathf.Sqrt(jumpHeight * -1f * gravity);
|
||||||
// jumped = true;
|
jumped = true;
|
||||||
// }
|
}
|
||||||
// if (context.canceled && !controller.isGrounded)
|
if (context.canceled && !controller.isGrounded)
|
||||||
// {
|
{
|
||||||
// jumped = false;
|
jumped = false;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
private void MyInput()
|
private void MyInput()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
"com.unity.2d.aseprite": "2.0.2",
|
"com.unity.2d.aseprite": "2.0.2",
|
||||||
"com.unity.ai.navigation": "2.0.9",
|
"com.unity.ai.navigation": "2.0.9",
|
||||||
"com.unity.cinemachine": "3.1.4",
|
"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.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.inputsystem": "1.14.2",
|
||||||
"com.unity.multiplayer.center": "1.0.0",
|
"com.unity.multiplayer.center": "1.0.0",
|
||||||
"com.unity.postprocessing": "3.5.1",
|
"com.unity.postprocessing": "3.5.1",
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.burst": {
|
"com.unity.burst": {
|
||||||
"version": "1.8.24",
|
"version": "1.8.25",
|
||||||
"depth": 2,
|
"depth": 2,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -71,18 +71,18 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.collab-proxy": {
|
"com.unity.collab-proxy": {
|
||||||
"version": "2.9.3",
|
"version": "2.10.2",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.collections": {
|
"com.unity.collections": {
|
||||||
"version": "2.5.7",
|
"version": "2.6.2",
|
||||||
"depth": 2,
|
"depth": 2,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.burst": "1.8.19",
|
"com.unity.burst": "1.8.23",
|
||||||
"com.unity.mathematics": "1.3.2",
|
"com.unity.mathematics": "1.3.2",
|
||||||
"com.unity.test-framework": "1.4.6",
|
"com.unity.test-framework": "1.4.6",
|
||||||
"com.unity.nuget.mono-cecil": "1.11.5",
|
"com.unity.nuget.mono-cecil": "1.11.5",
|
||||||
@@ -106,11 +106,11 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.ide.visualstudio": {
|
"com.unity.ide.visualstudio": {
|
||||||
"version": "2.0.23",
|
"version": "2.0.25",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.test-framework": "1.1.9"
|
"com.unity.test-framework": "1.1.31"
|
||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
@@ -233,7 +233,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.unity.splines": {
|
"com.unity.splines": {
|
||||||
"version": "2.8.1",
|
"version": "2.8.2",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.test-framework": {
|
"com.unity.test-framework": {
|
||||||
"version": "1.5.1",
|
"version": "1.6.0",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "builtin",
|
"source": "builtin",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -254,7 +254,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.unity.test-framework.performance": {
|
"com.unity.test-framework.performance": {
|
||||||
"version": "3.1.0",
|
"version": "3.2.0",
|
||||||
"depth": 3,
|
"depth": 3,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
m_EditorVersion: 6000.2.1f1
|
m_EditorVersion: 6000.2.13f1
|
||||||
m_EditorVersionWithRevision: 6000.2.1f1 (55300504c302)
|
m_EditorVersionWithRevision: 6000.2.13f1 (abdb44fca7f7)
|
||||||
|
|||||||
Reference in New Issue
Block a user