- Home /
The question is answered, right answer was accepted
Real gun range and rigidbody.addforce power?
Hello! I want to make my FPS game as accuratly as possible. How can I make the rigidbody.addforce so that it would be like a real gun? Like how what should I make the addforce integer to be in order to make it have a range like a pistol? Is there like a scale?
Answer by zados · Aug 02, 2013 at 12:37 AM
Generally at this point what you'll want to do is read up a little bit on physics specifically line collisions and bullet momentum based on gun type. I recommend the research because you used the word pistol.. there are a ton of pistols out there.. a 9mm berreta will not be as powerful as a 357 magnum and a desert eagle will be more powerful than that.
There 2 ways you can do this.. you can write your own physics (not recommended, but most accurate) or use the built in engine and give it a look and feel on how you want it just by eyeing everything.
What I would do is attach a rigid body to my bullet check the use gravity box and set a velocity for the object. You can technically use add force but you might get unintended results such as a bullet hitting a wall or a person could technically move it as the force would transfer. where on a velocity you can just set the velocity to 0 once it hits.. then set a timer for it to destroy it's self.
Hope this helps you out, good luck!
How would I make my own physics? Also, that was a great answer.
in unity when you make a game object there is a transform on it that lets you set positions. You can use that in conjunction with a mass and force variable to plot the position you would go based on rotation.
Your best solution would to be to go to goolge and look up physics tutorials that specifically work in movement, distance tracking, and collisions.
well the best way to do a gun is with a raycast... that way there is no "bullet" from the gun, just a line that projects from the gun when the fire button is pressed to a range you set. This way, you also avoid things like bullets going through objects/enemies because they are traveling to fast and pass through the collider ins$$anonymous$$d of colliding with it.
Follow this Question
Related Questions
Add force to a rigid body with raycast 1 Answer
How to fire a gun using raycasting and still add force 1 Answer
Why is velocity checking intensive? 0 Answers
How to move a rigidbody along a curve or spiral 0 Answers
AddForce to position on Rigidbody 2 Answers