- Home /
is there a way to limit the amount of AddForce?
i not want some thing to go infinalty fast , so i figure there must be a way to check either verlosity or something to limit the total force that addForce will apply over time.
can some one tell me the check that is used.
Answer by sparkzbarca · Oct 15, 2012 at 11:59 PM
when you add force use mathf.clamp
you just do
instead of velocity = forceadded;
velocity = mathf.clamp(forceadded, min, max);
where min is the lowest acceptable value for force added and max is the highest that will keep you from adding a huge amount of speed
if you want to limit velocity period
if(object.transform.velocity > highest_speed_ill_allow) { object.transform.velocity = highest_speed; }
the moment if goes over it'll get kicked back to max
Answer by MaKayata · Jul 19, 2015 at 01:22 AM
With this you don't change the value of addForce, but you will only disable to addForce in your addForce. It is not the perfect answer, but it works for me.
if(rgb.velocity.x < 80) {
rgb.AddForce(transform.right * 20);
Debug.Log(rgb.velocity.x);
}
Your answer
Follow this Question
Related Questions
AddForce to object 3 Answers
Change rigidbody's jumping speed 2 Answers
Adding force to rigidbody2d to slide 1 Answer
AddForce Relative to Rotation 1 Answer
Torque applied only after force 0 Answers