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 Tahj · Apr 29, 2012 at 12:39 AM · collisionsplatforms

Script for Vanishing Platforms

Hello,

I was wondering what is the best way to create a script that will make a platform disappear after a character controller collides with it, then leaves the platform. My intention is to have the a character jump onto the platform and when the character jumps off the platform will be destroyed. I have found a set of scripts in scripting reference called OnCollisionExit but have yet to find a way to utilize it for my needs. Is this the right approach or is there other pieces of script I should be looking into to better accomplish my needs?

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

Answer by stingman · Apr 29, 2012 at 01:12 AM

OnCollisionExit only works if you are working with non-kinematic rigidbodies and since you are using a character controller I suggest using OnControllerColliderHit if you want to go this route. There are several ways of doing this but I think an even easier way is to create a prefab of your jump platform and use OnTriggerExit instead. Just use an empty game object for the trigger and place it on top of your platform. When the player leaves the trigger code in 1 line to destroy the platform. simple and effective. But if you want to use oncontrollercollider hit you can do that as well. Just a lot more code to do the same thing

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 Tahj · Apr 29, 2012 at 06:17 PM 0
Share

Thanks for the feedback, it clarified things and allowed me to complete my script. I ended up going with your suggestion of using an empty gameobject, didn't realize that a collider could be placed upon it. Thanks again.

avatar image
0

Answer by devilkkw · Apr 29, 2012 at 01:05 AM

 function OnCollisionExit(collisionInfo : Collision) {
     
 
 //make sure collider is a player,in this case check the transform name,also use Tag
     
 if (collisionInfo.transform.name=="Player") Destroy (gameObject);//destroy immediately,use Destroy (gameObject,3); for destroy after 3 sec.
 }
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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How can I set the order of destruction of game objects? 1 Answer

How to import the object from server to unity 2 Answers

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 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