- Home /
Keeping character's movement consistent.
I'm still working on my rigidbody character, trying to figure out the best type of force mode to use while moving it.
I basically want my character to move at a constant 10mph, allowing for outside things to act on him. A force blowing him backward at 5mph will bring him to a total speed of 5mph. But how would I keep such a constant speed?
I've tried all manners of AddForce(desiredVelocity,ForceMode.Force), using mass, time, and such.
When I try to make a capped speed to reach, it manages to reach it no matter what forces are acting against it.
I also haven't been able to figure a way around the "floaty physics" of my own gravity forces.
Anybody have a definitive solution to this?
Answer by Loius · Oct 07, 2010 at 05:40 PM
You need to keep the character from exerting more force than they're capable of - calculate how much force you need to get to 10mph, and if that's more than the character can exert, just add their maximum exertion instead of how much they calculated that they need.
Or, whenever a force is applied to the character (e.g. froma wind zone), tell the character that its base velocity is no longer 0,0,0, but is instead that force.
That's what I'm trying to do. Assu$$anonymous$$g my character could instantly accelerate to his maximum force to bring him to 10mph, what function would I use to apply that?
After I find that out, I'll manually apply acceleration to where he can accelerate to said force.
I think you want Vector3.$$anonymous$$in( desiredForce, maximumForce )
Would I apply that with AddForce(force,Force$$anonymous$$ode.Force)? force*mass*Time.deltaTime,Force$$anonymous$$ode.Force, or even force*mass,Force$$anonymous$$ode.Impulse?
OH! I figured out my problem. I had $$anonymous$$ass set to 150!
Edit: Just realized I'm back where I started. I'm going to try something else...
Your answer
Follow this Question
Related Questions
Impulse to reach certain height? 1 Answer
Gravitational Object Creation for 3D Game 1 Answer
rigidbody.Velocity stops gravity 2 Answers
Simulate gravity on rigidbody 1 Answer
Firing projectile in curve 1 Answer