- Home /
Bullet Launcher Script
this is my script i got from unity tutorials, but for some reason on my multiplayer game it rotates downward and doesn't shoot straight. the bullets start working normal then go downward, then it shoots alot downward and only a few straight
var projectile : Rigidbody;
var speed = 20; function Update() { if( Input.GetButtonDown( "Fire1" ) ) { var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation ); instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) ); Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider ); } }
Look like the issue is with the transform you're using, when assigning position and rotation. Are you sure it's always pointing straight?
i position it 0,90,0 because if i did nto have that 90 it would be facing to the left should i try moving the player to the left ins$$anonymous$$d of the bullet?
that did not work either hmm maybe there is a different way you can script a rigid body to go forward when you click mouse button 0. like a vector3 forward or something.
Answer by FredVicentin · Nov 29, 2011 at 01:12 AM
If you want your bullet to go to infinity, go to the bullet prefab and set the Angular Drag to 0. So it will not slow down.
For better velocity, put a mass like 0.2, less mass, more speed.
This can work ;)
For more informations of Angular Drag:
http://unity3d.com/support/documentation/ScriptReference/Rigidbody-angularDrag.html You can also check the FPS tutorial of Unity:
http://unity3d.com/support/resources/tutorials/fpstutorial.html
that not the problem its something in the script or its having problems because of the multiplayer and all the networking scripts.
I know this question is like ... 3 weeks old ... but i gotta say this. Totaly wrong! $$anonymous$$ass only affects collisions... for example when an object with high mass hits something with low mass then the low-mass object is going to be pushed away ... and angular drag ... that should be set to something high tbh ... because you don't want your bullets to rotate... The very docs that you pointed at confirm this ... and contrary to what your instinct may tell you ... Unity3D mass doesn't affect speed/gravity AT ALL!
Your answer
![](https://koobas.hobune.stream/wayback/20220613055931im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Shooting with the maneuvering of the ship 0 Answers
Adding force to a bullet as it hits object? 2 Answers
Best way to shoot physical bullets? 2 Answers
How do add force from bullet on death? 1 Answer
Water Blob Bullet 3 Answers