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 /
This question was closed Jun 29, 2014 at 03:46 PM by tanoshimi for the following reason:

Please follow a tutorial to learn how to write scripts.

avatar image
0
Question by Paul_BadBoy · Jun 29, 2014 at 02:45 PM · triggercar

Help with trigger zone

Hi, I have a little car game, something similar to Hill Climb Racing, and I have a trigger zone at the end of the level. I tried some scripts that I found arond, but nothing worked. This is what I need: I have the car named "PickUp" and at the end of the level the trigger. When the car enters in the trigger zone, I want to load the menu. I tried to do a scri't myself, but didn't work. Thx.

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

  • Sort: 
avatar image
0

Answer by legion_44 · Jun 29, 2014 at 03:12 PM

Give Your car object (the one with collider if Your car is made from more parts) a tag "Car" and try this: (to add a tag, go to Edit->Project settings->Tags and Layers, and then in Yor car gameObject inspector, select Tag to Car)

 class LevelEnd : MonoBehaviour
 {
  void OnTriggerEnter(Collider c)
  {
   if(c.CompareTag("Car"))
   {
    Application.LoadLevel("Level Name"); //Or Application.LoadLevel(0); where 0 is level index in build settings
   }
  }
 }


And attach this script to trigger.

Hope that helps,
Paul

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 Paul_BadBoy · Jun 29, 2014 at 03:26 PM 0
Share

It gives me error at line 8 unexpected symbol and line 10 parsing error, a don't know anything about C#. Actually I know how it looks but writing the code...

avatar image pianobry · Jun 21, 2017 at 01:18 PM 0
Share

Could the error be due to the fact that you typed his commented code on a separate line?

Omit the red text: "//Or Application.LoadLevel(0); where 0 is level index in build settings"

Follow this Question

Answers Answers and Comments

23 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

Related Questions

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

Trigger GUI with a key when colliding (C#)? 1 Answer

Help with hiding an object on trigger enter 1 Answer

Animation triggered by an animation? 1 Answer

How do I make it so that when you pass over a line, you switch levels? 3 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