diff --git a/Assets/Materials/PlayerMaterial.physicMaterial b/Assets/Materials/PlayerMaterial.physicMaterial index 85fae2f..0162417 100644 --- a/Assets/Materials/PlayerMaterial.physicMaterial +++ b/Assets/Materials/PlayerMaterial.physicMaterial @@ -11,4 +11,4 @@ PhysicMaterial: staticFriction: 1 bounciness: 0 frictionCombine: 0 - bounceCombine: 0 + bounceCombine: 1 diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 121aee1..cd84058 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -219,8 +219,7 @@ MonoBehaviour: runningParticles: {fileID: 1608137079} rotationX: 0 mainObject: {fileID: 3244356567786994345} - jump: {x: 0, y: 20, z: 0} - jumpForce: 5 + jump: 0 isRunning: 0 --- !u!65 &1172583624 BoxCollider: @@ -550,7 +549,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 3244356567913423209} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.55, z: -0.68} + m_LocalPosition: {x: 0, y: 0.55, z: -0.805} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index bb22bd9..4ed3021 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -19,8 +19,7 @@ public class PlayerController : MonoBehaviour bool canMove = true; Rigidbody rb; float moveDirectionY; - public Vector3 jump; - public float jumpForce = 2.0f; + public bool jump = false; private bool isGrounded = false; public bool isRunning = false; @@ -33,7 +32,6 @@ public class PlayerController : MonoBehaviour rb = GetComponent(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; - jump = new Vector3(0.0f, 2.0f, 0.0f); } // Update is called once per frame @@ -61,13 +59,23 @@ public class PlayerController : MonoBehaviour if (Input.GetKeyDown(KeyCode.Space) && isGrounded) { - Debug.Log("Jump"); - rb.AddForce(transform.up * jumpSpeed * 500 * Time.deltaTime, ForceMode.Impulse); + jump = true; isGrounded = false; } rb.MovePosition(rb.position + moveDirection); } + + private void FixedUpdate() + { + if (jump) + { + Debug.Log("Jump"); + rb.AddForce(transform.up * jumpSpeed * 100 * Time.deltaTime, ForceMode.Impulse); + jump = false; + } + } + void OnCollisionExit(Collision other) { if (other.gameObject.tag == "platform")