Hello,
I am trying to add force to shoot a bullet I've Instantiated at the gun of my player. When I run the code the bullet just slowly floats up. If I add force to the bullet in it's own script it works fine, but not like this. I've tried both the commented and uncommented code below and it still doesn't work. Any help would be greatly appreciated! Thanks!
void FixedUpdate () {
if (Input.GetButtonDown ("Fire1")) {
Debug.Log ("Fired");
Rigidbody2D bulletInstance = Instantiate (playerShot, gun.transform.position, Quaternion.Euler (new Vector3 (0, 0, 0))) as Rigidbody2D;
//bulletInstance.rigidbody2D.AddForce(new Vector2(100f,0));
bulletInstance.rigidbody2D.velocity = new Vector2 (100, rigidbody2D.velocity.y);
}
}
↧