I am trying to allow my bullet to move forward and used rigidbody.addforce but realize it is accelerating.Can anybody tell me how do I solve it
else if(slow !fastforward !freeze)
{
bulletSpd=5.0f;
rigidbody.AddForce(transform.forward * bulletSpd);
}
Not sure without seeing the rest of the code, but “add force” is accumulative. Every time you call this, you add a little more motion to your rigidbody. So you need to ensure you only apply that force when wanted, such as if a ‘go’ button is held down. For a bullet, you can put the AddForce line in the Start() method and apply it only once when the bullet starts. Or add the force when you create the bullet, like this:
shot = Instantiate(bullet,transform.position, transform.rotation) as GameObject;
shot.rigidbody.AddForce(shot.transform.forward*bulletSpd);
I solve it by adding drag to the object
which would suggest you’re doing “+1 -1” every frame… rather than “+1 when applicable” (unless you’re modelling something like terminal velocity during a fall or maybe flight… then you’ve got it
)