.
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user