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 ctechnoboy87 · Mar 15, 2012 at 02:24 AM · cubeboxfallingrigid body

How make activate a Rigid body after object moves off an object?

How do you make a cube fall after you move a box on it then off it. So its there when you walk on it but when you walk off it falls doawn.

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
0

Answer by syclamoth · Mar 15, 2012 at 02:35 AM

There are a few ways, but the simplest one (the one I'd go for) would be to link a trigger volume on top of it, something like this:

First, make your rigidbody block, nice and simple. Set it to 'kinematic' so that it doesn't just fall straight away.

Then, make an invisible, trigger collider that sits above it, and add something similar to the following script:

public Rigidbody linkedBlock;

void OnTriggerExit(Collider other) { if(/other is the player, determine this however you like- / true) { // Make the block fall! linkedBlock.isKinematic = false; // makes sure it only works once gameObject.active = false; } }

Then, make sure that you assign the correct block to the 'LinkedBlock' property, and set up some system for determining which object the player is, and you're set to go!

Comment
Add comment · Show 7 · 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 ctechnoboy87 · Mar 17, 2012 at 12:58 AM 0
Share

Sorry about repost (new). O$$anonymous$$ im slightly confused on what i need to change in code. I made linkedblock;Platform which is what i want to fall and everything else im confused on. Cube is player that moves around, Trigger is the trigger, and Platform is what needs to fall.

avatar image syclamoth · Mar 17, 2012 at 05:28 AM 0
Share

Oh, you're working in JavaScript? Why? Also, you should have told me.

Seriously, this is working code here. Just make the Platform a rigidbody, so that it can fall (otherwise it won't ever fall without special code), and make sure that the player can trigger triggers (needs to have at least one rigidbody involved).

Here's a javascript version, if you want:

 var linkedBlock : Rigidbody; // Assign this in the editor
 function OnTriggerExit(other : Collider)
 {
     if(/*other is the player, deter$$anonymous$$e this however you like- */ true)
     {
         // this section has to be activated by some conditional that makes sure that
         // it's the player, not something else.
         linkedBlock.is$$anonymous$$inematic = false;
         gameObject.active = false;
     }
 }

Put that script on a trigger, and then drag the platform onto the slot exposed in the inspector. I'm really not sure how much more clear I can make this.

avatar image ctechnoboy87 · Mar 19, 2012 at 10:40 PM 0
Share

Do I put this in function start, update, or neither. I changed if (/other is the player, deter$$anonymous$$e this however you like- / true) to if (gameobject.Cube = true) not sure if I did that right and when I try to run it, it says compiler errors.

avatar image Dakwamine · Mar 19, 2012 at 11:02 PM 0
Share

What does compiler says?

avatar image ctechnoboy87 · Mar 19, 2012 at 11:09 PM 0
Share

Need to fix all compiler errors.

Show more comments
avatar image
0

Answer by reganmusic · Nov 16, 2012 at 04:35 AM

I have many "Collider" in my scene that are likely to pass through my trigger box, but I only want my player to set off the trigger box, is "Collider" the word that I need to be replacing in this script? If so... what with?

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How make an object fall after a cube moves off the object? 1 Answer

3D Cubes vibrating and sliding while ontop of eachother 0 Answers

Falling off respawn 4 Answers

Falling Objects Sound 1 Answer

Respawn after falling off script? 2 Answers


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