• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by conflictbliz · Nov 28, 2011 at 11:03 PM · rigidbodybulletlauncher

Bullet Launcher Script

t$$anonymous$$s 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 ); } }

Comment

People who like this

0 Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Demigiant · Nov 28, 2011 at 11:17 PM 0
Share

Look like the issue is with the transform you're using, when assigning position and rotation. Are you sure it's always pointing straight?

avatar image conflictbliz · Nov 28, 2011 at 11:40 PM 0
Share

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 instead of the bullet?

avatar image conflictbliz · Nov 28, 2011 at 11:49 PM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image

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.

T$$anonymous$$s 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

Comment

People who like this

0 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image conflictbliz · Dec 03, 2011 at 01:28 AM 0
Share

that not the problem its something in the script or its having problems because of the multiplayer and all the networking scripts.

avatar image IT_Criminal · Nov 21, 2012 at 02:12 PM 0
Share

I know this question is like ... 3 weeks old ... but i gotta say this. Totaly wrong! Mass 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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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 to correctly go about adding bullet/projectile speed? 1 Answer

How do add force from bullet on death? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges