using System;
using UnityEngine;
namespace Controller
{
public class Player : MonoBehaviour
{
private Vector3 _moveDirection;
private bool _pressedJumpButton;
[SerializeField] private CharacterController _controller;
[SerializeField] private float _speed;
[SerializeField] private float _gravity;
[SerializeField] private float _jumpHeight;
public void Movement(Vector3 direction)
{
if (_controller.isGrounded == true)
{
_moveDirection = direction;
_moveDirection *= _speed;
}
if (_pressedJumpButton == true)
{
_moveDirection.y = _jumpHeight;
_pressedJumpButton = false;
}
_moveDirection.y -= _gravity * Time.deltaTime;
_controller.Move(_moveDirection * Time.deltaTime);
}
public void Jump()
{
_pressedJumpButton = true;
}
}
}
Using the code, help add the ability for velocity cut and coyote time in the context of a 2.5D platformer.