Rigidbody2D AddForce doesn't work
I have a sprite ball with Rigidbody 2D, Circle Collider 2D and with this script:
public float thrust;
public Rigidbody2D ball;
// Use this for initialization
void Start () {
ball = GetComponent<Rigidbody2D>();
ball.AddForce(new Vector2(0,1), ForceMode2D.Impulse);
}
But my ball is not moving, why? (Yes my rigidbody is assigned to public variable Rigidbody 2D)
Answer by Kossuranta · Apr 10, 2017 at 12:34 PM
First of all if you have assigned the ball variable already in inspector then you can remove the first line of the Start method as that will reassign the ball variable with the objects own Rigidbody2D component.
Script seems to be just fine and I doubt that that is the problem. My guess would be that you have something wrong with your Rigidbody2D component settings.
First of all Body Type has to be Dynamic
Simulated has to be true
If you have high Mass you need to add more force than 1 unit
If you have high Linear Drag then the object might pretty much stop immediately
If you have gravity and try to move against that you might also need more than 1 unit of force
Constraints for the axis you want your object to move has to be false
Answer by Jaz30 · May 10, 2018 at 12:21 AM
Hi @tomsk , maybe you need to put your "AddForce" line of code into void Update() function not in void Start(). Correct me if I'm wrong, void Start() is triggered once the game start/script start, then the AddForce script won't work there.
xD no man, he can do it in every void but the update is called evey frame and the start only at the start,isn't that the probelm
Your answer
![](https://koobas.hobune.stream/wayback/20220612115044im_/https://answers.unity.com/themes/thub/images/avi.jpg)