Hi there, I’ve been experimenting with trying to move a rigidbody at a constant velocity.
Initially I applied a force in FixedUpdate, then scaled up the drag of the object relative to it’s velocity, so the faster it is the more drag is applied:
referenceToRB.AddForce (Vector3.right * 5.0f, ForceMode.Force);
float drag = ReturnNormalisedVelocity () * maxDrag;
drag = Mathf.Clamp(drag, 0.0f, maxDrag);
referenceToRB.drag = drag;
However the object kept accelerating. I also tried an alternative method and called the following in void Start () - so one call:
referenceToRB.AddForce (Vector3.right * 5.0f, ForceMode.VelocityChange);
Again the object kept accelerating. But I then read about a little known class called ConstantForce - just what I was looking for (or so I thought):
constantForce.force = Vector3.right * 5.0f;
However, the object still doesn’t appear to be traveling at a constant velocity (it keeps increasing in velocity). I’ve turned off other forces such as gravity and set the the object and the object it moves across physics materials to ‘ice’, but still it behaves the same.
Am I misunderstanding the point of this function or just using it incorrectly?
Thanks
Ant