Rigidbody.AddForce not working no matter what
So i want to move an object when i shoot it, but no matter what i do AddForce() doesn't do anything.
Here's the important parts of my gun code (i still don't understand the formatting here so i'll just use pastebin):
https://pastebin.com/hBtFuyNR
And no matter what i do the object doesn't move. All i've done to test it is to place a sphere, given it a rigidbody component and it doesn't move. I've changed it's mass, changed the force to 30000f, but it just refuses to move. Also, i know that the ray is hitting the object (Debug.Log(hit.collider.gameObject.name) logs the right name), so it's not a collider issue either.
So what am i doing wrong? Thanks!
Answer by Tntman93 · Aug 21, 2021 at 10:09 PM
Solved it, the answer was literally in the question below mine.
To anyone wondering, here's the solution.
Basically, change GetComponent<Rigidbody>().AddForce(transform.up * 100f)
to GetComponent<Rigidbody>().AddForce(transform.up * 100f, ForceMode.Impulse)
.