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 Bob5602 · Feb 14, 2011 at 05:22 PM · velocityspeedmomentum

Neutralize momentum for better turning with physics

Hello -

I am running into a somewhat conceptual problem with my space ship movement. I am using AddRelativeForce to make the ship move forward toward a target, and theoretically the ship is always facing the target. When its straight, it works just fine. However, if the target moves during this the forward momentum I am adding onto my ship with AddRelativeforce isn't always in the same direction, and I get this (physically accurate..) momentum so the ship misses the target, flying around it in an arc.

This is fine in theory, but I want to make a function that will straighten out the ship so it flies forward, without the momentum.

I am currently using a way that stores the current rigidbody.velocity in a variable (velocity), then sets rigidbody.velocity to zero, then changes rigidbody.velocity = velocity.magnitude (for the speed it was going) * transform.forward (so it takes that original speed and changes it into forward motion). This is working just fine, but I end up with an unnatural stop type thing.

I want to make a function with a name something like "StraightenOut" so it takes the velocity, and slowly over the course of 2 seconds (using Time.deltaTime I think would be best..) switches the sideways velocity to be forward velocity. It would work in the sense that each time the function is run (x number of times over the course of 2 seconds) it subtracts a little bit from the current rigidbody.velocity and then adds it back in going in the forward direction. However, I am trying to keep me speed, or rigidbody.velocity.magnitude, to be relatively the same as it changes the velocity. The problem I am running into is that since my forward additions are changing my rigidbody.velocity each frame, I'm always adding / subtracting a different number and not a percentage of the original velocity. Does anyone know a way I can structure such a "straighten out" function and make my straightening out business a bit more natural looking?

Thanks!

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

No one has followed this question yet.

Related Questions

Rigidbody speed / Velocity issue 0 Answers

Speed based on distance 1 Answer

Kinematic how to know rigidbody velocity vector? 1 Answer

Change bouncing angle with touching speed 1 Answer

Can an object to transfer to another as it increases your speed? 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