- Home /
Question by
csgeorge · Oct 15, 2016 at 10:43 PM ·
rigidbodyaddrelativeforce
AddRelativeForce- Faster While Jumping
I'm using AddRelativeForce for my character movement, and if you move in the air while jumping, there is a noticeable increase in speed. I'm guessing that being on the ground is causing some kind of friction that slows the character down? Not sure, but what I want is simply for my character to move at the same speed whether it is in the air or on the ground. Any help appreciated.
float v = Input.GetAxis("Vertical") * speed;
float h = Input.GetAxis("Horizontal") * speed;
v *= Time.deltaTime;
h *= Time.deltaTime;
//Moves character in vertical and horizontal axes based on WASD.
if(Input.GetButton("Vertical"))
{
rb.AddRelativeForce(0,0,v, ForceMode.Impulse);
}
if(Input.GetButton("Horizontal"))
{
rb.AddRelativeForce(h,0,0, ForceMode.Impulse);
}
Comment