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 vakkeh · Oct 06, 2018 at 01:30 PM · rigidbodyissuetreeflying

Trees are flying when rigidbody is activated

(Here is a video) https://streamable.com/xdzu6

I'm trying to make a tree fall when it's health is 0. I then add rigidbody and use AddForce to make it fall, but it flies instead. I also tried setting it's mass and drag to some crazy high number with no success.

My Code:

 private void Update()
     {
         if(Health <= 0 && !chopped)
         {
             Rigidbody _rb = this.gameObject.AddComponent<Rigidbody>();
             _rb.mass = 100;
             _rb.drag = 1000000;
             _rb.useGravity = true;
             _rb.AddForce(Vector3.forward, ForceMode.Impulse);
             _rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ;
             chopped = true;
 
         }
 
         if(chopped)
         {
             StartCoroutine(RemoveFromScene());
         }
     }

If anyone has any idea what could be wrong please tell me, it's been driving me crazy.

Thanks.

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 CodeElemental · Oct 06, 2018 at 01:50 PM 0
Share

It's because the pivot point of the collider (used for rotation) is in the center of the collider. Try offsetting it so it rotates around the bottom (I'm assu$$anonymous$$g it's behavior you want).

avatar image vakkeh CodeElemental · Oct 06, 2018 at 02:25 PM 0
Share

Hey, thanks, I don't really know what a pivot point of a collider is, but I've tried to lower the collider, so it's more at the bottom. Now it's beahving even weirder.

(Video of that) https://streamable.com/tibxs

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by itsharshdeep · Oct 06, 2018 at 04:10 PM

Hi @vakkeh,

Kindly check the following script and video, this might help you out:

  • Script: https://pastebin.com/6N7j3qe2

  • Video: https://www.dropbox.com/s/oh1k26heotfk5lg/TreeFalling.mov?dl=0


I believe you need to :

  1. Remove the constraint

  2. Add collider to ground

  3. Add force towards the required direction

  4. The pivot should be correct

Hope that will help you out.

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

123 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

Related Questions

Rocket-styled angular drag 0 Answers

Fly Mode 2D + Rigid Body vs CharacterController problems 0 Answers

Rigidbody + Character Controller = flight? 1 Answer

Gently Restricting Helicopter Rigidbody Movement 0 Answers

Enemy floating problem 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