Character Controller - Limit controller speed
Hello,
I'm currently working on an FPController and thus far things are going well. I've been working on perfecting the air control however I've come across an issue with controller speed.
Currently, a player can jump and will retain their velocity even if they let go of the inputs which is exactly what I want to happen. The only problem is, I also want some slight air control. Here's what I have so far.
private void HandleMovement()
{
input = GetPlayerInput();
if (controller.isGrounded)
{
isJumping = false;
controller.slopeLimit = 45.0f;
velocity = input * speed;
if (Input.GetButton("Jump"))
{
isJumping = true;
velocity.y = jumpHeight;
controller.slopeLimit = 90.0f;
}
else
{
if ( controller.velocity.magnitude < (speed - 1f) )
{
velocity += input * airSpeed;
}
}
velocity.y -= gravity * Time.deltaTime;
If I remove the check against the velocity of the controller, the player will zoom across the screen. What I'd like to do is allow the player to continue to move/direct themselves mid air, while limiting their speed if they reach a speed limit. Is there a way to achieve this?
I've tried to set a cap and tried to apply some air resistance, but this never seems to actually make any impact to the movement i.e. multiplying by 0.3f
Thanks.