TRIGGER TO LAUNCH GAME
Hi, in the throws of creating my first game after months of learning how to use Unity. Trying my hand scripting for the first time.
Using Unity 5.6
I am setting up a trigger to enter my game instead of using a menu. I have a car driving into a cube which is then supposed to launch the next scene.
I have a collider on the Cube.
This is what I have now:
Yet, I get an error message of:
Assets/LoadSceneMazeMadness8.js(8,1): BCE0044: expecting }, found "
Any thoughts welcome.
Answer by VeeooshL · Apr 05, 2017 at 08:14 PM
this is an easy mistake to make. After a '{' you must add a closing '}' to encase it. Below is the same code, with two more '}' to end the if() statement and the OnTriggerEnter():
#pragma strict
function OnTriggerEnter(other : collider){
//if a game object with the tag 'Car' enters the scene, load a scene
if(other.gameobject.tag == "Car"){
SceneManager.LoadLevel('MazeMadness8'
} // <-- here
} // <-- and here
Also, it is good to indent the code inside the OnTriggerEnter() and the if()
Answer by SlateOne · Apr 05, 2017 at 09:53 PM
VeeooshL,
Many thanks for the quick reply. I'll drop that in tomorrow and see how it goes. Will come back to you with results.
Midnight here, time to retire..
Ron.
glad I could help :) I know how it is to have just started coding in c#, it is very confusing. if you haven't already, I recommend following one of the unity tutorials that $$anonymous$$ches you how to make a game. here is a list. they are fully documented and really easy: https://unity3d.com/learn/tutorials