• 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
0
Question by impurekind · Aug 20, 2018 at 07:43 PM · velocityspeedforcemotion

How do I give my ejected bullet shell a speed plus the player's current speed?

If my player is running around in the game and I eject a shell from $$anonymous$$s gun when I fire, how do I make sure the speed the shell travels is in addition to the speed the player is already moving?

Basically, I want it to always look like the shell is flying out and off to the right of the gun regardless of what direction the player is running around in or how fast they are moving, as it looks wrong just now with the shell looking like it's flying more to the left if I move right and more to the right if I move left, so I want to set the shell's speed on top of whatever speed the player is already moving in whatever direction.

You know, like if I throw somet$$anonymous$$ng w$$anonymous$$le stationary vs in a ve$$anonymous$$cle moving at 60mph, the object will travel at its normal speed plus my current speed so it will actually be moving faster if I throw it from the moving car.

Comment
Add comment · Show 4
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 Piyush_Pandey · Aug 21, 2018 at 10:07 AM 0
Share
avatar image impurekind Piyush_Pandey · Aug 21, 2018 at 05:01 PM 0
Share
avatar image JVene · Aug 21, 2018 at 06:18 PM 0
Share
avatar image impurekind JVene · Aug 21, 2018 at 07:06 PM 0
Share

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by JVene · Aug 21, 2018 at 08:37 PM

Get the Rigidbody component of the gun. Instantiate the casing, let's say it's 'c'. Get 'c's Rigidbody, then copy the gun's velocity with somet$$anonymous$$ng like:

  c_rb.velocity = gun_rb.velocity;

Where c_rb is the casing's Rigidbody, and gun_rb is the gun's Rigidbody. Then apply the ejection force.

Comment
Add comment · Show 7 · 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 impurekind · Aug 23, 2018 at 01:45 PM 0
Share
avatar image JVene impurekind · Aug 23, 2018 at 06:25 PM 0
Share
avatar image impurekind JVene · Aug 23, 2018 at 11:31 PM 0
Share
Show more comments

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

93 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Increasing the speed of a ball in a brick breaker game 0 Answers

Using rigidbody.AddForce and speeding the object 2 Answers

How to get collision force, not relative velocity? 1 Answer

i am not able to increase the speed of ball perodically in pong, in this code the speed of ball decrease while playing so help with this, how to increase speed of ball perodically?, 0 Answers

Make an object move forward on its own 2 Answers


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