- Home /
Constant force, not constant at all!!
Hello.
I have attached a constant force component to a rigid body and then I use **transform.constantForce.force = (transform.forward 50);*
But, by time the speed keeps increasing, so its not constant,not at all.. And another problem, it wont even update when I rotate the object, keeps going on the old axis.
Am I missing something, or what ? I am getting crazy here trying to make a cube move by force which should be like humanoid constant force.
Are you constantly reapplying the multiplied force in Update or FixedUpdate?
I use FixedUpdate , and an Input.Get$$anonymous$$ey().
If you only want 1 hit of force, try Get$$anonymous$$eyDown
Thanks all for answers! I think I misunderstood what acceleration,velocity and force means. Thanks to you I now know,and I managed to fix what I needed.
Answer by drod7425 · Nov 06, 2013 at 03:09 PM
If I'm reading the documentation correctly - http://docs.unity3d.com/Documentation/Components/class-ConstantForce.html - it looks like constant force applies linear acceleration to an object. So imagine you're in a car and you press the gas pedal all the way down. You're not going to be go 100MPH immediately. It will take some time for the car to get up to that speed and, depending on your car, it might get there. But throughout the acceleration to 100, you're not increasing the amount of force (ie. pushing the gas pedal down farther). You're applying a constant force and your car is going faster and faster.
If you want a constant speed, try using Transform.Translate - https://docs.unity3d.com/Documentation/ScriptReference/Transform.Translate.html
Hope that helps!
Answer by Bunny83 · Nov 06, 2013 at 03:05 PM
It seems you are a bit confused about force and velocity. A constant force will linearly accelerate your object. If you want a constant velocity, just set the velocity of the rigid body once. If you set "drag" to 0 (which simulates air-resistance) the velocity will stay constant and moves the object at the same speed.
Answer by tanoshimi · Nov 06, 2013 at 03:08 PM
ConstantForce will apply the force every frame until you change the force. Please check your code and ensure that you are only setting the constant force once, not calling it in a loop, for example.
If you only want the force to be applied while a key is held, say, then you should be looking at AddForce instead.
Oh, that might be more what OP's looking for. I thought OP didn't want to see acceleration.
It also depends whether we're talking about an object moving in frictionless space, in which case I agree with your answer that it's constant velocity the OP is looking for, not constant force. However, if it's a body experiencing drag, resistance, or friction on a surface, constant force will be required to maintain s$$anonymous$$dy state. We need more info to tell!