- Home /
Lerpz LevelStatus script
Hi
Win7 64bit pro Unity 3.5.6f4
Lepz code copied from the tutorial .pdf appendix throws up these errors in the above mentioned unity3d version:
There are semicolons already present on the lines indicated by the console and the unexpected token is not apparent from the report. I am guessing this is just a version disparity issue. Documentation is a beast for sure but this is a great tutorial and the folks at unity should fix it if it isn't already being adapted for version 4. Being almost at the end I am sort of curious how the scenes will work so any help on the script would be greatly appreciated.
Cheers and thanks in advance.
The scripting in the appendix:
// LevelStatus: Master level state machine script.
var exitGateway: GameObject;
var levelGoal: GameObject;
var unlockedSound: AudioClip;
var levelCompleteSound: AudioClip;
var mainCamera: GameObject;
var unlockedCamera: GameObject;
var levelCompletedCamera: GameObject;
// This is where info like the number of items the player must collect in order to
complete the level lives.
var itemsNeeded: int = 20; // This is how many fuel canisters the player must collect.
private var playerLink: GameObject;
// Awake(): Called by Unity when the script has loaded.
// We use this function to initialise our link to the Lerpz GameObject.
function Awake()
{
levelGoal.GetComponent(MeshCollider).isTrigger = false;
playerLink = GameObject.Find("Player");
if (!playerLink)
Debug.Log("Could not get link to Lerpz");
levelGoal.GetComponent(MeshCollider).isTrigger = false; // make very sure of this!
}
function UnlockLevelExit()
{
mainCamera.GetComponent(AudioListener).enabled = false;
unlockedCamera.active = true;
unlockedCamera.GetComponent(AudioListener).enabled = true;
exitGateway.GetComponent(AudioSource).Stop();
if (unlockedSound)
{
AudioSource.PlayClipAtPoint(unlockedSound,
unlockedCamera.GetComponent(Transform).position, 2.0);
}
yield WaitForSeconds(1);
exitGateway.active = false; // ... the fence goes down briefly...
yield WaitForSeconds(0.2); //... pause for a fraction of a second...
exitGateway.active = true; //... now the fence flashes back on again...
yield WaitForSeconds(0.2); //... another brief pause before...
exitGateway.active = false; //... the fence finally goes down forever!
levelGoal.GetComponent(MeshCollider).isTrigger = true;
yield WaitForSeconds(4); // give the player time to see the result.
// swap the cameras back.
unlockedCamera.active = false; // this lets the NearCamera get the screen all to
itself.
unlockedCamera.GetComponent(AudioListener).enabled = false;
mainCamera.GetComponent(AudioListener).enabled = true;
}
function LevelCompleted()
{
mainCamera.GetComponent(AudioListener).enabled = false;
levelCompletedCamera.active = true;
levelCompletedCamera.GetComponent(AudioListener).enabled = true;
playerLink.GetComponent(ThirdPersonController).SendMessage("HidePlayer");
playerLink.transform.position+=Vector3.up*500.0; // just move him 500 units
if (levelCompleteSound)
{
AudioSource.PlayClipAtPoint(levelCompleteSound, levelGoal.transform.position,
2.0);
}
levelGoal.animation.Play();
yield WaitForSeconds (levelGoal.animation.clip.length);
Application.LoadLevel("GameOver"); //...just show the Game Over sequence.
}
Answer by dpk · Nov 18, 2012 at 06:53 AM
I suspect the issue is that "complete the level lives." word wrapped on to another line. If I copy and paste your exact text above I get the same error, and the syntax highlighting in MonoDevelop shows the "complete the level lives." text in black, indicating it's no longer in a comment.
Answer by kanga · Nov 18, 2012 at 10:39 AM
Assets/Scripts/Misc/LevelStatus.js(43,1): BCE0005: Unknown identifier: 'itself'.
Yep. That was it plus another one you see above which is the same wrap error. Well done solved.
Cheers
Answer by kanga · Nov 18, 2012 at 10:39 AM
I would vote the answer up but the forum wont let me. Thanks again.
Your answer
Follow this Question
Related Questions
Errors when following the Rolling Ball script tutorial. 2 Answers
Can't follow "roll a ball" tutorial. No cube rotate or GUI count. 2 Answers
Lerpz Adventure Tutorial - Start Menu 2 Answers
Lerpz Tutorials Animation Problem 0 Answers
JetPackParticleController not working in the 3D Platformet Tutorial 0 Answers