I’m using
rigidbody.AddRelativeForce
the problem is, how do I stop it?
rigidbody.AddRelativeForce(Vector3.zero);
does not work, is there any way to over ride it, or stop it? as it seems to just += everytime theres a new call.
I’m using
rigidbody.AddRelativeForce
the problem is, how do I stop it?
rigidbody.AddRelativeForce(Vector3.zero);
does not work, is there any way to over ride it, or stop it? as it seems to just += everytime theres a new call.
what are you aiming for? A complete instantaneous stop (kinematic = true) or just removing the force from the object (constantForce.relativeForce.x/y/z=0)?
well it’s an airplane.
The problem is, as I go foward and turn, it keeps going in the old direction, until I call relvativeforce again, but then it’s kind of moving in both new and old.
i tried
rigidbody.AddRelativeForce(Vector3.zero);
rigidbody.AddRelativeForce(transform.forward * 20)
as to stop old and re call new, but it doesn’t work;
I’m not sure exactly what’s causing the problems you’re seeing, but I think you might not be fully understanding what adding a force does (which may be part of the problem).
An applied force only has a direct effect for the (fixed) update in which it’s applied, so the way to stop applying a force is to stop applying the force, essentially.
Also, this:
rigidbody.AddRelativeForce(Vector3.zero);
Is essentially a no-op. Basically, what you’re saying is, ‘don’t apply any force to this object’. What does a box sitting on the floor (most likely) do when you don’t push it? It just sits there. Applying a force of (0, 0, 0) basically equates to ‘not pushing the box’.
In other words, this code:
rigidbody.AddRelativeForce(Vector3.zero);
Has exactly the same effect as this code:
If you want the effect of a previously applied force to be countered in some way, one way to do that is to adjust the linear drag property of the rigid body appropriately (higher values will cause the object to accelerate more slowly and slow down more quickly, in general). If you want a more specific effect, another option would be to apply a force that counters the first force to some degree.