Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Apr 25, 2014 at 12:12 PM by Bunny83 for the following reason:

Problem is not reproducible or outdated

OP has stated his problem is fixed and has abandoned this thread at Mar 24

avatar image
1
Question by SenorFlowers · Mar 24, 2014 at 09:59 PM · collisioncollidertriggerrestartplatform-support

How to restart scene with trigger?

Hello all, I'm very new to Unity but I have some ideas on how to use it. For an assignment, I have to learn how to use triggers and restart the game when one enters it. Right now I have a sprite with the tag "Player" and accompanied by a Character Controller. The "Player is going to be chased by a gas cloud (tagged as "Gas") and when he enters its trigger, the game restarts. The "Gas" is a sprite that moves on its own. The game is running on a 2D plane, like a platformer. Right now, I have an empty game object that is child to "Gas" and made it into a sphere collider. Also, "Gas" does not have a rigid body. I didn't think it would need one seeing that "Player" already has the Character Controller attached. My script is as follows:

 #pragma strict
 
 function Start () 
 {}
 
 function OnTriggerEnter (player : Collider) 
 {
      if(player.gameObject.tag == "Player")
         Application.LoadLevel(Application.loadedLevel);
 }
 function OnTriggerExit (player : Collider)
 {
     if(player.gameObject.tag == "Player")
     Application.LoadLevel(Application.loadedLevel);
 }

This code doesn't seem to work, so what can I do to have the game restart when my "Player" sprite enters the trigger? Please help!

Comment
Add comment · Show 7
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 getyour411 · Mar 24, 2014 at 09:59 PM 1
Share

put debug in ontrigger and ensure you are getting the triggerevent you expect to

avatar image instruct9r · Mar 24, 2014 at 10:01 PM 0
Share

Application.LoadLevel(Application.loadedLevel);

in the braces, you have to put the number / name of the level, that you want to load.

avatar image Lo0NuhtiK · Mar 24, 2014 at 10:03 PM 0
Share

@instruct9r ... Doing it the way they did IS putting a number in as the level they want to load. Application.LoadLevel(Application.loadedLevel); will re-load the current level.

avatar image Fappp · Mar 24, 2014 at 10:05 PM 0
Share

Do you have a rigidBody attached to one of the colliders?

avatar image Bunny83 · Mar 25, 2014 at 12:16 AM 0
Share

@SenorFlowers: Don't post an answer just with the text "fixed it". Either post a real answer which actually answers / solves the problem or if you think the question won't help others, close it. If you can't close it just ask for close with a comment.

Show more comments

1 Reply

  • Sort: 
avatar image
0

Answer by abdala · Mar 25, 2014 at 01:37 AM

 #pragma strict
  
 function Start ()
 {}
  
 function OnTriggerEnter (player : Collider)
 {
 Application.LoadLevel(LEVEL NAME);
 }
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

Follow this Question

Answers Answers and Comments

26 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

Related Questions

How to make work a collision when is invisible? 3 Answers

Overlap point of 2 kinematic colliders 1 Answer

How do you execute Trigger-collider collision only in one gameobject? 1 Answer

Prevent shooting when gun is inside wall 1 Answer

How to get collision point when using onTriggerEnter 5 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