• 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 hypnoslave · Mar 21, 2011 at 07:53 AM · physicsrigidbodycenterofmass

Changing a rigidbody's center of mass, to get a natural rotation while it moves through the air

Hey folks. I'm trying to make an object similar to javelin, which rotates naturally as it flies through the air, as you'd expect from an object which has it's center of mass located in the tip.

Problem is, I'm not have any of my desired results from setting the centerOfMass variable in my object's rigidbody, which I assumed would do the trick. Perhaps I'm using it incorrectly?

any idea how i can accomplish this? I need the movement of this object to be perfect.

Comment
Add comment · Show 1
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 Jean-Fabre · Mar 21, 2011 at 09:45 AM 0
Share

Could you share a sample project? that would help tweaking what you have. So many params comes into account, that it difficult to answer such question without a proper base.

4 Replies

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

Answer by efge · Mar 21, 2011 at 01:41 PM

You could also take a look at this answer: Realistic rotation of flying arrow?

Comment
Add comment · Show 6 · 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 tool55 · Mar 21, 2011 at 05:51 PM 0
Share

That's a good link, too. The slerp solution doesn't seem so great, but the LookRotation (last entry) in this link should work. Just moving mass around isn't going to do much. The tail feathers of an arrow have much more to do with it arcing downward than mass placement. Drag is the key if you want to go the physics route, but coding is really the best (and least expensive) way to go.

avatar image tool55 · Mar 21, 2011 at 05:55 PM 0
Share

And just as a thought, it would be nice if the Unity folks could make drag moveable like mass through code. Don't know if this is even possible, but it would be nice for flight sims etc. to be able to have greater air drag at one end of a rigidbody than the other without having to link a separate rigidbody with a joint. Just a wish, but not essential :)

avatar image efge · Mar 21, 2011 at 06:05 PM 0
Share

You do not have to use a joint, just create empty game objects as children, attach rigidbodies and set different values for drag etc.

avatar image tool55 · Mar 21, 2011 at 07:44 PM 0
Share

You might be right. Tried that in a flight sim a while back and it didn't work so well. I found that separate rigidbodies attached with fixed joints gave me more control and allowed me to apply physical forces on, for example, a plane wing, that I couldn't achieve by parenting. But for a javelin, parenting is worth a try. Would certainly be simpler!

avatar image hypnoslave · Mar 25, 2011 at 03:44 PM 0
Share

Forgot to reply! sorry all. yeah, the LookRotation in the last entry of that post was the most effective and easy solution for this problem. Thanks a lot!

Show more comments
avatar image
0

Answer by alcatraz5 · Apr 30, 2014 at 12:53 PM

Fixed -create a empty game object -than add your movement script to it -delete remove the movement script from the javelin game object, if any but keep the rotation script -drag javelin game object to the new game object just created......

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

Answer by tool55 · Mar 21, 2011 at 01:32 PM

Here's a link to a similar thread:

http://forum.unity3d.com/threads/22063-I-shot-an-arrow-up-in-the-air...?highlight=shooting+arrow

Personally, I would code the rotation using LookAt as GargarathSunman suggests in this link, but if you want to do it with physics, you'll probably need to build the javelin in at least a couple of parts, as the others suggest in the link, and add different drag and angular drag values to each part,perhaps density as well. If you threw a javelin in a vacuum, it would never land point down because air drag plays such an important part (all things fall at the same rate regardless of mass, thank you Sir Isaac Newton). It's a difficult simulation for the physics engine to get right.

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

Answer by Skjalg · Mar 21, 2011 at 09:53 AM

Make a gameobject that has your rigidbody attached to it, with its center of mass in the middle. Then create a child gameobject and attach your javelin model to that and offset it correctly so that the parent gameobject is close to the tip.

That should make it work as you intend :)

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

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

2 People are following this question.

avatar image avatar image

Related Questions

Problem with Rigidbody.CenterOfMass 2 Answers

How can I rotate around with a Rigidbody while respecting physics? 0 Answers

AddRelativeTorque() Applied Incorrectly When Using a Custom Centre of Gravity 0 Answers

AddRelativeTorque results in incorrect angular acceleration (Maybe centrifugal force affects) 0 Answers

Is there a way to draw center of mass on the screen? 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