You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/body/Body.js
+14-7Lines changed: 14 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -801,15 +801,22 @@ var Axes = require('../geometry/Axes');
801
801
};
802
802
803
803
/**
804
-
* Applies a force to a body from a given world-space position for a _single update_, including resulting torque.
805
-
* The position must be specified. Using `body.position` results in zero torque.
804
+
* Applies the `force` to the `body` from the force origin `position` in world-space, over a single timestep, including applying any resulting angular torque.
806
805
*
807
-
* Forces create an acceleration that acts over time, so may need to be applied over multiple updates for the body to gain a visible momentum.
806
+
* Forces are useful for effects like gravity, wind or rocket thrust, but can be difficult in practice when precise control is needed. In these cases see `Body.setVelocity` and `Body.setPosition` as an alternative.
808
807
*
809
-
* See also `Body.setVelocity` and related methods which do not require any time for acceleration to reach the given velocity.
808
+
* The force from this function is only applied once for the duration of a single timestep, in other words the duration depends directly on the current engine update `delta` and the rate of calls to this function.
809
+
*
810
+
* Therefore to account for time, you should apply the force constantly over as many engine updates as equivalent to the intended duration.
811
+
*
812
+
* If all or part of the force duration is some fraction of a timestep, first multiply the force by `duration / timestep`.
813
+
*
814
+
* The force origin `position` in world-space must also be specified. Passing `body.position` will result in zero angular effect as the force origin would be at the centre of mass.
815
+
*
816
+
* The `body` will take time to accelerate under a force, the resulting effect depends on duration of the force, the body mass and other forces on the body including friction combined.
810
817
* @method applyForce
811
818
* @param {body} body
812
-
* @param {vector} position
819
+
* @param {vector} position The force origin in world-space. Pass `body.position` to avoid angular torque.
813
820
* @param {vector} force
814
821
*/
815
822
Body.applyForce=function(body,position,force){
@@ -988,7 +995,7 @@ var Axes = require('../geometry/Axes');
988
995
989
996
/**
990
997
* A `Vector` that accumulates the total force applied to the body for a single update.
991
-
* Force is zeroed after every `Body.update`, so constant forces should be applied for every update they are needed. See also `Body.applyForce`.
998
+
* Force is zeroed after every `Engine.update`, so constant forces should be applied for every update they are needed. See also `Body.applyForce`.
992
999
*
993
1000
* @property force
994
1001
* @type vector
@@ -997,7 +1004,7 @@ var Axes = require('../geometry/Axes');
997
1004
998
1005
/**
999
1006
* A `Number` that accumulates the total torque (turning force) applied to the body for a single update. See also `Body.applyForce`.
1000
-
* Torque is zeroed after every `Body.update`, so constant torques should be applied for every update they are needed.
1007
+
* Torque is zeroed after every `Engine.update`, so constant torques should be applied for every update they are needed.
1001
1008
*
1002
1009
* Torques are converted to acceleration on every update, which depends on body inertia and the engine update delta.
0 commit comments