- Home /
Question by
csgeorge · Oct 18, 2016 at 05:08 PM ·
rigidbodyspeedaddrelativeforce
How do I make my character's speed stay consistent?
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
Your answer
Follow this Question
Related Questions
Rigidbody magnitude 3 Answers
Set MINIMUM speed? 1 Answer
instantiated objects have different speed 1 Answer
Limiting the top speed of a rigidbody in 3d space? 1 Answer
How to Limit Speed of a Rigidbody? 2 Answers