Version: 5.6 (switch to 2017.1b)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Rigidbody2D.AddForceAtPosition

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function AddForceAtPosition(force: Vector2, position: Vector2, mode: ForceMode2D = ForceMode2D.Force): void;
public void AddForceAtPosition(Vector2 force, Vector2 position, ForceMode2D mode = ForceMode2D.Force);

Parameters

force Components of the force in the X and Y axes.
position Position in world space to apply the force.
mode The method used to apply the specified force.

Description

Apply a force at a given position in space.

The AddForce function applies a force that acts straight through the rigidbody's centre of mass and so produces only positional movement and no rotation. AddForceAtPosition can apply the force at any position in world space and will typically also apply a torque to the object which will set it rotating. Note that for the purposes of this function, the rigidbody is just a coordinate space of infinite size, so there is no reason why the force needs to be applied within the confines of the object's graphic or colliders.

See Also:: AddForce, AddTorque, AddForceAtPosition, ForceMode2D.