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
-1
Question by Peanut97 · Apr 13, 2013 at 05:12 PM · ontriggerenterdeathapplication.loadlevelload level

LoadLevel help!

Hey all,

I've been working with Unity for a while now, but I seem to be stumped by this one. Currently, I am making a horror game where you are stuck inside of a basement while a monster is chasing you. I'm using a trigger system to send the player to the death screen (new scene) when he touches the monster. The problem I am running into is whenever the monster touches ANY object, it sends me to the death screen. Is it possible to load a level ontriggerenter ONLY when the player enters the trigger? THANK YOU! It means a lot!

~Unity lover!

Comment
Add comment · Show 3
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 DaveA · Apr 13, 2013 at 05:15 PM 0
Share

Please post your code so we can see what's going on

avatar image DryTear · Apr 13, 2013 at 06:02 PM 0
Share

Please post the OnTriggerEnter() part of the code, with out, its almost impossible to answer your question.

avatar image Peanut97 · Apr 13, 2013 at 07:53 PM 0
Share

Thank you guys for helping me out! Sorry, I should have posted the code earlier. Here it is:

 function OnTriggerEnter (other : Collider)
 {
     Application.LoadLevel (1);
 }
 

Whenever the monster touches walls, I get teleported into the death screen. Can you guys help me out? Thanks.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by DryTear · Apr 13, 2013 at 06:07 PM

Place this piece of code on your player:

 OnTriggerEnter(c : Collider){
     if(c.gameObject.tag == "Monster"){
         Application.LoadLevel(1);
     }
 }


On your Monster GameObject, set his tag to "Monster", and make an EmptyGameObject with a collider set to isTrigger, and place this collider onto the monster as a child like so:

 Monster
     Trigger
Comment
Add comment · Show 2 · 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 Peanut97 · Apr 13, 2013 at 06:20 PM 0
Share

Hey, DryTear! Thank you so much for your help, man! I appreciate it! I believe this is going to work, but Unity is throwing up some errors with the script. It says "Unexpected Token: "c"" and it says it has some problems with the colons/semicolons. Any ideas? Thanks again!

avatar image DryTear · May 01, 2013 at 12:09 AM 0
Share

Are you using C# or Java?

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

12 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

Related Questions

Multiple Cars not working 1 Answer

Application.LoadLevel error 1 Answer

Death upon health = 0 2 Answers

HELP PLEASE! 3 Answers

how do i make a sound effect play when the player dies 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