Difference between revisions of "Body:applyForce"
m (1 revision: Importing from potato (again).) |
m (→See Also: Add some related functions) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
Apply force to a Body. | Apply force to a Body. | ||
− | A force pushes a body in a direction. A body with with a larger mass will react less. The reaction also depends on how long a force is applied: since the force acts continuously over the entire timestep, a short timestep will only push the body for a short time. Thus forces are best used for many timesteps to give a continuous push to a body (like gravity). For a single push that is independent of timestep, it is better to use [[Body: | + | A force pushes a body in a direction. A body with with a larger mass will react less. The reaction also depends on how long a force is applied: since the force acts continuously over the entire timestep, a short timestep will only push the body for a short time. Thus forces are best used for many timesteps to give a continuous push to a body (like gravity). For a single push that is independent of timestep, it is better to use [[Body:applyLinearImpulse]]. |
Line 8: | Line 7: | ||
Note that the force components and position must be given in world coordinates. | Note that the force components and position must be given in world coordinates. | ||
+ | == Function == | ||
+ | {{newin|[[0.8.0]]|080|type=variant}} | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | Body:applyForce( fx, fy ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|number|fx|The x component of force to apply to the center of mass.}} | ||
+ | {{param|number|fy|The y component of force to apply to the center of mass.}} | ||
+ | === Returns === | ||
+ | Nothing. | ||
+ | |||
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
Line 20: | Line 31: | ||
=== Returns === | === Returns === | ||
Nothing. | Nothing. | ||
+ | |||
== See Also == | == See Also == | ||
* [[parent::Body]] | * [[parent::Body]] | ||
+ | * [[Body:applyTorque]] | ||
+ | * [[Body:applyLinearImpulse]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | {{#set:Description=Apply force to a Body. | + | {{#set:Description=Apply force to a Body.}} |
− | }} | + | {{#set:Since=000}} |
+ | |||
+ | == Other Languages == | ||
+ | {{i18n|Body:applyForce}} |
Latest revision as of 19:00, 25 November 2019
Apply force to a Body.
A force pushes a body in a direction. A body with with a larger mass will react less. The reaction also depends on how long a force is applied: since the force acts continuously over the entire timestep, a short timestep will only push the body for a short time. Thus forces are best used for many timesteps to give a continuous push to a body (like gravity). For a single push that is independent of timestep, it is better to use Body:applyLinearImpulse.
If the position to apply the force is not given, it will act on the center of mass of the body. The part of the force not directed towards the center of mass will cause the body to spin (and depends on the rotational inertia).
Note that the force components and position must be given in world coordinates.
Contents
Function
Available since LÖVE 0.8.0 |
This variant is not supported in earlier versions. |
Synopsis
Body:applyForce( fx, fy )
Arguments
number fx
- The x component of force to apply to the center of mass.
number fy
- The y component of force to apply to the center of mass.
Returns
Nothing.
Function
Synopsis
Body:applyForce( fx, fy, x, y )
Arguments
number fx
- The x component of force to apply.
number fy
- The y component of force to apply.
number x
- The x position to apply the force.
number y
- The y position to apply the force.
Returns
Nothing.
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info