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 /
  • Help Room /
avatar image
0
Question by Abotics99 · Dec 19, 2015 at 09:04 AM · collisionrigidbodydestruction

Super simple rigid body destruction, how?

You know in GTA or the older midtown madness games you can drive into a lamp post or other objects and they would fall over? If I just use a normal rigid body it will fall over without being hit so how would I only activate a rigid body after it has been hit with, say, a collider from any other object?

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

1 Reply

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

Answer by jrjr · Dec 19, 2015 at 09:53 AM

This might not be the best method but should work. I just tested it and it does. I was thinkin this same thing about 3 weeks ago while messing around with GTA 5 for first time.

For test - Make two cubes. In blank scene. The first one is your mover (car or person or whatever). The first one should have a kinimatic (for test purposes at least) rigidbody and a collider.

The second cube just has a box collider set to trigger. You shouldnt even need a actual collider on it (other than the trigger, i dont think this affects performance now with 5.x but that's a hunch after lots of messing with it).

Then you do - void OnTriggerEnter(Collider other){ if (other.gameObject.name.Contains("Cube")){ other.gameObject.AddComponent (); }

You have to add rigidbody with greater than less than signs around it right after addcomponent.. it's not showing up in the comment sorry. In a small script on the kinimatic cube.

Hit play, drag your cube with kinimatic rigid body on it into the other cube and it will fall as you are wanting.

I don't know about any static checkbox effects with this that could be bad but if you have it marked static your mesh will stay where it is and your collider will fall (which will make it look like it didnt work unless you have it selected. Just wanted to mention that because it looks damn confusing at first but makes sense.

After your objects done bouncing around you should have something in a script on it to destroy both the rigidbody (if you don't want it to move anymore) and the script that's going to remove that rigid body itself). You could also just keep track of those objects in a list on your kinematic moving body and just deactivate those later though (might save some script room, depends on your situation).

j

Comment
Add comment · Show 4 · 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 jrjr · Dec 19, 2015 at 09:59 AM 0
Share

I haven't tested turning off static at runtime yet... actually I just hit a static cube with the above test and the mesh followed. Odd. I've seen this not work before perhaps its something recently added or to do with convex meshes (mainly what i was working with at the time).

Just something to look out for.

Good luck man.

avatar image jrjr · Dec 19, 2015 at 10:14 AM 0
Share

Actually 1 more thing - I think I know what you're ai$$anonymous$$g at and want to add a few things to it to save you some serious time if you are not aware of it:

First off you need to quarantine your objects off into sections if you are going to have a lot of them that are able to be knocked around this way. $$anonymous$$ake separate scene sub objects and put those hitable objects into those so you can keep track of them and modify them better.

Second you should be deactivating, removing from the scene, or pooling these kinds of objects or even groups of them or sections of your map that are not going to be in view (if its gonna be a big map). So for example - your big buildings and stuff you can see from far away are LOD based and grouped into a particular bunch that is active when you know they are going to be visible so you can make them so ( this is going to save your balls on occlusion and camera rendering).

You can do similar things for smaller objects (debris, lamp posts, mailboxes, garbage cans,... etc) and have those groups activate on larger trigger based zones.

I'm still only into this less than 2 years but we just got our third multiplayer to run at 60fps with practically no traffic net wise with 400 plus monsters in the scene - very exciting! We're just about to break into big scene creation and the above points are only a portion of whats needed to make it work right.

Feel free to email me at jro$$anonymous$$e2445@gmail.com if ya have any other questions you dont get answered in a day or so I don't check on here much in the past year.

avatar image Abotics99 · Dec 19, 2015 at 06:17 PM 0
Share

The snippet of code works beautifully and I totally get it! Thanks so much for the help and good luck on your project.

avatar image Abotics99 Abotics99 · Dec 19, 2015 at 06:31 PM 0
Share

I changed it from looking for a name to looking for a tag I will put on multiple objects. Which will hopefully make it more efficient for me to apply to other assets.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Is it more efficient to leave a rigidbody as isKinematic and activate it when needed, or to just add it in game? 0 Answers

Is it more efficient to set a rigidbody to isKinematic and activate it if needed, or to just add one realtime? 0 Answers

Copy collision object position (Or just "fly" a little bit) 0 Answers

Rigidbody going through wall during pinch-to-zoom 0 Answers

Rigidbody going through Colliders help! 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