- Home /
Question by
Sparky64 · May 02 at 07:19 PM ·
physicscharactercontroller
Trying to make a way to allow sideways movement while doing a physics slide
if(sliding && Input.GetKeyDown(crouchkey) && !running)
{
sliding = false;
}
else if(Input.GetKeyDown(crouchkey) && !sliding && running)
{
running = false;
sliding = true;
rb.AddForce(moveDirection * extraslideforce * rb.mass, ForceMode.Impulse);
}
if(sliding)
{
// (i don't know how to keep it slowing down but allow the player to move a bit)
rb.AddForce(slidemoveDirection.normalized * slidemovespeed * rb.mass, ForceMode.Force);
}
if(rb.velocity.magnitude <= (basemovespeed * 0.6f)/12.5f)
{
sliding = false;
}
this code is to manage a first person physics slide where if the velocity gets under a certain speed it stops sliding automatically (using the drag values of the physics system if that's important), i'm trying to implement a way so that the player can make adjustments to the sliding however adding a force just adds to the velocity
Comment
Your answer
