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 Rineocerous · Jul 27, 2013 at 08:51 PM · physicstriggerdelay

How to time delay change of physics state via trigger?

So I have rigidbody game objects that fall from a platform and pile up on the floor. Because this pile can get quite large I want to save on physics by switching them to kinematic after they've come to rest on the floor. The problem I have with using 'sleep' is that before the fall the objects need to interact with eachother in a way where they can't sleep too quickly and on the ground new objects keep coming from above and colliding with the objects on the ground so they never have a chance to fall asleep. Obviously I'm trying to find a solution where none of the pieces end up frozen in the air so my concept was to have them pass through a trigger with a time delay that would give them enough time to come to rest and turn off the physics before a new piece lands from above.

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
1
Best Answer

Answer by robertbu · Jul 27, 2013 at 09:02 PM

If you know approximately know when they get launched and approximately how long they take to fall, why not avoid the trigger and just put a generous time limit. You could predicate your isKinematic on the object having no velocity. Assuming the timer starts when object is created you can some something like:

 function Start() {
   InvokeRepeating("Solidify", 3.0, 0.1);
 }
 
 function Solidify() {
   if (rigidbody.velocity == Vector3.zero) {
      rigidbody.isKinematic = true;
      CancelInvoke("Solidify");
   }
 }

So this code waits 3 seconds. Then it tries 10 times a second to make the object kinematic. It only makes it kinematic if the object has no velocity. If you want to use a trigger, you fire of the InvokeRepeating() in OnTriggerEnter().

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 Rineocerous · Jul 27, 2013 at 11:43 PM 0
Share

That's a brilliantly simple solution my friend and I really appreciate it. I'm sticking with the trigger because the platform, while always above the floor, can rise to substantial heights which of course changes the time it take for the object to reach the floor. I've had some issues that require rebuilding the scene so i can't test it immediately but I'll be sure to update this post once I do. Thanks again!

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

15 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

Related Questions

Is there a way to deny an exit (and therefore OnTriggerExit) 2 Answers

Collider/trigger collision causing physics glitch 0 Answers

Inconsistent Trigger events 1 Answer

overlapsphere to destroy NPCs on exit 1 Answer

Collider Lifts me off Ground ??? And I'm afraid of heights !!! 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