Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 f03n1x · Oct 30, 2017 at 01:46 AM · rotationgameobjectrigidbody

Issue with an object rotating strangely

So I've created a script that creates a forest, with that each tree is procedurally generated though only being slightly different (the variances could be slightly taller by having one or two middle log bits,change in rotation and of course change in position). For this example I have an AI controller cube that walks up to trees and cuts them down, then cuts them into logs.


At the moment everything with that works fine, however the tree itself being made up of three types of 3D models (trunk, middle and top) when the tree the cut down, the middle logs can be cut further into it's smaller parts. Which can be cut further into planks.


However the issue revolves around the first middle log that being the one closest to the trunk, when it separates from it's child object, it starts to randomly rotate to be standing up right. I made a Gif of the problem:

[link text][https://imgur.com/lhXszZ7]


The remaining children objects are completely fine, they don't have the issue that the first log did, I'm not doing anything to specifically cause the object to do this weird rotation.


Just for reference how the tree is made, there is an empty game object being the parent of the whole tree, then followed by the trunk and so on. I.E. like this

     -EmptyGameObject
        -child of empty Game object:Trunk
           -child of Trunk: Log1
             -child of Log1: Log2
               -child of Log2: TreeTop


The game objects are very straightforward, they include a Mesh renderer, mesh collider. The rigid body is added when the object is cut down (to all children).


I've tried searching up anything related to this bug but I can't seem to find anything similar to it.

[1]: https://imgur.com/lhXszZ7


Sorry about the horrible setup, I'm still learning the whole markdown thing. I'll try my best to edit it until it looks nice enough to read.


Also if someone needs to see the code I use, I can provide snippets it just depends on the specific bits since there is a couple scripts.

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

2 Replies

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

Answer by FlaSh-G · Oct 30, 2017 at 10:01 PM

Seeing that gif, I can tell that the chunk has an incorrect center of mass.

The center of mass is a Vector3 that defines the relative center of mass of a rigidbody. A thing that is made of a heavier material on one side than the other will have its center of mass moved towards that side. Rigidbody.centerOfMass allows you to implement that in your game.

In your case, the center of mass seems to be outside the physical shape of the object, causing it to rotate around its edge, and eventually to stand up.

Your primary course of action should be to find out why the center of mass is set inappropriately. If you should then happen to find out that there's not much you can do about it, consider using Rigidbody.ResetCenterOfMass after cutting to fix it.

Comment
Add comment · Show 1 · 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 f03n1x · Oct 30, 2017 at 10:04 PM 0
Share

Thanks! I will definitely try it out, but it seems like it's the proper answer to this annoying problem, I think it maybe because the objects are parented that it sees all the objects as part of one object. Again thank you. I guess any update to the rigid body seemed to reset it but yes definitely finding the real reason behind it all helps a lot.

avatar image
0

Answer by f03n1x · Oct 30, 2017 at 09:54 PM

So I've figured out a way to get around this issue, any modification to the rigid body at all causes it to act normally. So in this case I changed the angular drag to 1.0f.


It isn't the most Ideal answer but it gets the job done.


If anyone has any better ideas please tell me, I'd rather do a proper way or at least try to understand what the underlying problem is here.

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.

Follow this Question

Answers Answers and Comments

143 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 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

Why does my rigidbody slows down at time ? 1 Answer

How to tilt the gameobject based of Input.Acceleration? 0 Answers

Make Rigidbody Object stand back up. 0 Answers

Player movement in the direction of rotation INACCURATE? 3 Answers

There is no 'Rigidbody' attached to the "Cube" game object, but a script is trying to access it,There is no Rigidbody attached to the Cube game object. 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