Rigidbody.addForce is not working

hey I am trying to make my character fire a bullit, i use this code to instantiate the bullit and add force to it! but some how the bullit is not getting move by the force!

   if(Input.GetButtonDown ("Fire2"))
        var bullit = Instantiate (bullitPrefab, gameObject.FindWithTag      ("spawnPoint").transform.position,gameObject.FindWithTag("spawnPoint").transform.rotation); 
        bullit.rigidbody.AddForce(transform.forward * 200);

can u guys help me here?

bullit.rigidbody.AddForce(transform.forward * 200,ForceMode.Impulse);

Does your "Gun" have a collider? If it does then the bullet collide with your "Gun" before it can ever fire out right...

Your bull*E*t object is missing a rigidbody or its rigidbody is kinematic. If that's not the problem you'll have to specify exactly what does happen when you press "Fire2".

I found this way works the best:

Vector3 direction = Vector3.zero;
direction = Vector3.forward * amtOfForce;
rigidbody.AddForce(direction * Time.fixedDeltaTime, ForceMode.Acceleration);

use transform.forward if vector3.forward isn’t right, your amtOfForce has to be really high, just for a jump i had to set my force float to 15000, this should be placed in a FixedUpdate if posible and always used Time.fixedDeltaTime for physics

hope this helps someone else wondering why addforce doesn’t work

I know this is kinda old, but for the sake of the Community, are you sure you want to use AddForce?

I made an FPS a while back and I used 'rigidbody.velocity'.

bullit.velocity = transform.TransformDirection(new Vector3(0,0,speed));

NOTE: This is C#, I don't know what it would be like in Js.

EDIT: 'speed' would be an int or a float with the value of how fast you want the bullet to be shot.

I know this post is really old, but I came across the same problem and I realised the transform.forward is a Vector3.zero, it is at (0,0,0) because of your rotation.

So if you do a Vector3.zero * 200 is a Vector3.zero and adding a force of ZERO will do nothing.

I’m leaving this if someone else has the same thing.

i checked all of the above and that wasn’t it, then i found that my drag was set at 100 and i could put a nuclear bomb up its behind and nothing happened. then i dropped the drag to 10, and it worked, (using ForceMode.VelocityChange) .

if you are using a ForceMode that uses mass, check your mass.

I know this is a very old post, but its the first to pop up on a google search.

For anyone having this issue, the other posts in this feed all show different ways of moving an object but if these are not working the issue may be with the Mass in the Rigidbody of the object you’re trying to shoot. The lower the mass, the easier it is to move.

try like me

First make sure that you have a Rigidbody component attached to your bullet.
Then try this:

 bullit.GetComponent<Rigidbody>().AddForce(transform.forward * 200 * Time.deltaTime);