Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 charglerode · Jul 24, 2014 at 12:50 AM · physicsrigidbodyvelocity

Sum of multiple velocities

I have a player object that can shoot a projectile at a velocity of x. When the player starts moving forward, I need the projectile velocity to now be the sum of the player's forward velocity y and the projectile's base velocity of x.

What I currently have is:

 projectile.velocity = (projectile.transform.forward + player.transform.forward) * projectileSpeed;

This doesn't seem to work.

How would I do this?

Comment
Add comment · Show 2
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 cdrandin · Jul 24, 2014 at 12:53 AM 0
Share

Well what affect is happening? If both are looking down the x axis. Then both forwards would be (0,0,1). so, (0,0,2) * mult.

avatar image charglerode · Jul 24, 2014 at 12:58 AM 0
Share

What's happening right now is the projectile will fly at it's normal speed. Once the player moves forward, any new projectiles will appear to move slower because the player is effectively catching up to it, if that makes sense.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Razacx · Jul 24, 2014 at 01:07 AM

 projectile.velocity = projectile.transform.forward * projectileSpeed + player.rigidbody.velocity;

player.transform.forward is merely a vector that describes how the object is rotated.

Comment
Add comment · 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 charglerode · Jul 24, 2014 at 01:11 AM 0
Share

Seems to have worked perfectly. $$anonymous$$y thanks!

avatar image JacobHockey13 · Jul 24, 2014 at 01:45 AM 0
Share

@charglerode If you are satisfied with the answer and it is correct, then hit the checkmark to accept as the right answer which will gain you and @Razacx karma.

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Add velocity relative to ground? 1 Answer

Problem Trying to Apply Non-Kinematic Velocity to Rigidbody 0 Answers

Inconsistent Rigidbody2D velocity. 0 Answers

What is the velocity on a given axis of a rigidbody? 2 Answers

Setting rigidbody.velocity giving unexpected result. 0 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