- Home /
Prefab bullet affected by gravity when it shouldnt?
I have a sphere that I can shoot from my character. I have turned off Drag, Angular Drag, Use Gravity, and have set the mass to 1e-07 (Well I tried 0, but thats what the GUI set it to).
Now when I 'fire' the sphere at the target, it moves towards the target, but if the target is some distance away, the path of the projectile decays as though gravity was still affecting it. Ideally I want the sphere to travel in a straight line until its destroy timer kills it (So it moves over the target marker and continues)
So what else do I need to set or tweak?
One thought was that my target is currently at a different height to the firing point, so I am wondering if it is the transform that is inducing an arc, but I dont know the math / functions to stop this happening.
Turning off gravity is generally all you need. How are you moving it?
$$anonymous$$ost people just do a LookAt to the target and set rigidbody.velocity
to transform.forward
. No Update code. Gives straight-line motion.
I ended up assu$$anonymous$$g it was a nob mistake. I turned off gravityseveral times. Eventually I saved the scene and it seemed to stick.
On with my next task and no doubt problem :)
Answer by shadowriffe · May 25, 2012 at 06:56 PM
http://unity3d.com/support/documentation/Components/class-Rigidbody
Enable isKinematic. Will not be affected by gravity.
is$$anonymous$$inematic will not allow him to use forces on the bullets.
Thanks, at the moment I'm just playing about, so that should be fine, though it would be good to identify the root cause.
@$$anonymous$$attR: Don't post chit-chat as answer. Use comments!
If you disabled Use Gravity there is not gravity applied. You either apply your own force in a wrong way, or it might have collided with something else so the path has changed. If no external forces are applied a Rigidbody moves on a straight line. $$anonymous$$ake sure you don't spawn your bullet inside you character, that will cause a penalty force since you collide with your player.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071930im_/https://answers.unity.com/themes/thub/images/avi.jpg)