diff --git a/Assets/Scenes/Scene1-1.unity b/Assets/Scenes/Scene1-1.unity index aa0b5a9..48caa37 100644 --- a/Assets/Scenes/Scene1-1.unity +++ b/Assets/Scenes/Scene1-1.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5fcdb460f80cc0909eec92f627019859c2e32912d802b1e86ed3e335d32044ae -size 1418572 +oid sha256:45e662a6d764db3a65a4d42d11e16424c6e7197795621b3365c1f155e88d4af9 +size 1418586 diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index 7d64717..fa23a43 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -77,6 +77,15 @@ public class PlayerMovement : MonoBehaviour public GameObject uiController; + public PlayerInput playerInput; + + InputAction jumpAction; + + private void Awake() + { + jumpAction = playerInput.actions["Jump"]; + } + void Start() { cinemachineCam = GameObject.Find("CinemachineCamera"); @@ -86,6 +95,7 @@ public class PlayerMovement : MonoBehaviour void Update() { + timeSinceLastSwing += Time.deltaTime; if (timeSinceLastSwing > .5f) lastSwing = 0; @@ -190,16 +200,21 @@ public class PlayerMovement : MonoBehaviour // controller.Move(move2 * Time.deltaTime); //} controller.Move(velocity * Time.deltaTime); - if (!controller.isGrounded) + if (!controller.isGrounded && !jumpAction.WasPerformedThisFrame()) { velocity.y += gravity * Time.deltaTime; } - else if (controller.isGrounded) + else if (controller.isGrounded && !jumpAction.WasPerformedThisFrame()) { - //velocity.y = 0; + 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) { @@ -275,18 +290,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() {