Before updating to Windows 10 you may need to return your Pro license. More information here

A little help with a orb script

Hi Im having a bit of trouble with a script for my platform game. The scripts (there are two) are made in Javascript, since thats the only language i know. The scripts are supposed to turn on and off an orb at the end when you collect a certain amount of points. But the script doesnt do that. Up until now i have had help from a lot of people creating this script and i have finally managed to turn the orb offline... however, now i cant turn the orb back on.

Here are the two script:

Main "Points System" script:

 //Variable for current Score
 var score = 0;
 //Variable for text showing score 
 var scoreText = "Score: 0";
 //Variable for the skin of the GUI
 var mySkin : GUISkin;
 //Variable for end orb
 var Orb = false;
 function OnTriggerEnter( other : Collider ) {
     Debug.Log("OnTriggerEnter() was called");
     if (other.tag == "Glowball") {
         // Sets a message in the log
         Debug.Log("Other object is a glowball");
         score += 1;
         scoreText = "Score: " + score;
         //Tells log what score is
         Debug.Log("Score is now " + score);
 function Update(){
     if (score >= 4){
 function ActivateOrb(){
     var orb = GameObject.Find("orb");
     if (orb != null) {
         gameObject.active = true;
         Orb = true;
 function OnGUI () {
     GUI.skin = mySkin;
     GUI.Label (Rect (10, 10, 500, 200), scoreText.ToString());

And here is the script for the "orb":

 function Start() {
     gameObject.active = false;
 function OnTriggerEnter( other : Collider) {
     if (gameObject.active){
 function YouWin(){
     //Show the win screen and results
     yield WaitForSeconds(2); //So the player can see the results

I really hope someone can help since this is the last script i need done for the gameplay.

more ▼

asked Jun 03, 2011 at 10:12 AM

avatar image

-4 4 4 4

Hello! When posting some code please highlight it and press the "10101" button it will make it a lot more readable.

I already did this for you.

Jun 03, 2011 at 11:03 AM OrangeLightning

Secondly there is no JAVA inside Unity3D, its Javascript and thats NOT the same.

Jun 03, 2011 at 11:31 AM BerggreenDK

Sorry but you knew what i meant so i cant see the big deal in that

Jun 04, 2011 at 11:00 AM SVL1002

Its about being precise as your questions and answers will be in here for everyone else, forever. So the less attention we pay to details, the worse the result. Again, I just added it as a comment, I didnt vote you down for it. You on the other hand ought to edit your own question and FIX the error. Thats how communities like this work. Keep up the good work. :o)

Jun 04, 2011 at 11:12 AM BerggreenDK
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Read through the script, it looks fine. I wouldn´t use gameObject.Find thought.

more ▼

answered Jun 03, 2011 at 11:48 AM

avatar image

7.4k 48 56 111

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments


asked: Jun 03, 2011 at 10:12 AM

Seen: 678 times

Last Updated: Jun 04, 2011 at 11:33 AM