- Home /
Question by
Bry_Perk · Jun 13, 2015 at 09:41 PM ·
rigidbody2daddforce
Rigidbody2D.AddForce fails to add force
I have a script that applies a 2D force to a bullet when instantiated then applies an equal force in the opposite direction on a rocket that the bullet is being fired from. The bullets work perfectly, but the rocket fails to move in the slightest. The code is as follows:
if (Input.GetMouseButtonUp (0)) {
GameObject bullet = Instantiate (bulletPlayer, rocket.transform.position, rocket.transform.rotation) as GameObject;
bullet.GetComponent<Rigidbody2D>().AddForce (transform.right * 1000,ForceMode2D.Force);
GetComponent<AudioSource>().Play();
rocket.GetComponent<Rigidbody2D>().AddForce(transform.right * -1000,ForceMode2D.Impulse);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613200945im_/https://answers.unity.com/themes/thub/images/avi.jpg)