Hot to identify a C# script in unityscript within this AI script?

Hey guys im trying to get this script to start mission two by identifying these enemies that will be throughout the scene this is what I have so far this script is in Java but the enemyAi (line 71) script is in C# and it wont identify it take a look… everything else works fine

enum GameState{ BeforeStart, Running, Finished }
enum MissionState{ One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Complete}

var activeSentries: int = 0;
var activeDemons : int = 0;



var gameState : GameState = GameState.BeforeStart;
var missionState : MissionState = MissionState.One;

function Update(){
if ( gameState == GameState.Running ) {
        if ( activeSentries == 0 ) { // objective complete
           gameState = GameState.Finished;
           missionState = MissionState.Two;
        }
    }
}

function OnGUI(){
    if (gameState == GameState.Finished ) { // only show this when the state is "Finished"
       GUI.Box(Rect(Screen.width - 200, Screen.height - 275, 175, 125), "Mission Complete");
       GUI.Label(Rect(Screen.width - 200, Screen.height - 250, 150, 125), " Click on Next Mission when ready ");

        if ( GUI.Button(Rect(Screen.width - 180, Screen.height - 148, 125, 25), "Next Mission") ) {

             // load next level here. 
             gameState = GameState.BeforeStart;

       }

   }


                                         ///////Mission One////////////

    if (gameState == GameState.BeforeStart  missionState == MissionState.One) { // only show this before the game actually starts
             GUI.Box(Rect(Screen.width - 200, Screen.height - 275, 175, 125), "New Mission");
             GUI.Label(Rect(Screen.width - 200, Screen.height - 250, 150, 125), " Destroy 10 Sentry Guns  ");
             
             if(GUI.Button(Rect(Screen.width - 180, Screen.height - 150, 125, 25), "Start Mission")){
					//gameState = GameState.Running;
                  // find all sentries in the current level
                  var sentries : SentryGun[] = FindObjectsOfType(SentryGun) as SentryGun[];  // this assumes that your sentry gun script  class is named "SentryGun"

               for (var sentry: SentryGun in sentries) {
                      // enable it
                      sentry.enabled = true;
                      activeSentries ++; // and take note of the active sentries.
       }

                 gameState = GameState.Running; // finally set game state to "Running". Now the update method will check the remaining sentries.
                // when your sentry is destroyed, you need to decrease the activeSentries variable by one, that needs to be done elsewhere.

            }           
    }




                                       ///////Mission Two////////////
                                       
      if (gameState == GameState.BeforeStart  missionState == MissionState.One) { // only show this before the game actually starts
             GUI.Box(Rect(Screen.width - 200, Screen.height - 275, 175, 125), "New Mission");
             GUI.Label(Rect(Screen.width - 200, Screen.height - 250, 150, 125), " Destroy 10 Sentry Guns  ");
             
             if(GUI.Button(Rect(Screen.width - 180, Screen.height - 150, 125, 25), "Start Mission")){
					//gameState = GameState.Running;
                  // find all sentries in the current level
                  var demons : Demon[] = FindObjectsOfType(enemyAi) as Demon[];  // this assumes that your sentry gun script  class is named "SentryGun"

               for (var demon: Demon in demons) {
                      // enable it
                      demon.enabled = true;
                      activeDemons ++; // and take note of the active sentries.
       }

                 gameState = GameState.Running; // finally set game state to "Running". Now the update method will check the remaining sentries.
                // when your sentry is destroyed, you need to decrease the activeSentries variable by one, that needs to be done elsewhere.

            }           
    }
       
    
}

can anyone help me out with this greatly appreciate it.

–RIO

Start by posting the errormsg.

If you dont get en errormsg, its because line 71 returns null because you have the cast set to “as Deamon[ ]” place the cast before (Deamon[ ])FindObjectsOfType(enemyAi) and you’ll probably get en errormsg failing to cast what it is it is returning.

here they go thing is when I create a empty java script it goes away thou…here are some pictures1363343--67992--$D.PNG

1363343--67993--$e.PNG

I think it has something to do with the script being C# like I say the error disappear if I create a empty java script named enemyAi also the C# enemyAi script was in existence before this objectives script and too it works fine for the sentries above in mission one difference is finding the SentryGun javaScript

It looks like you are just enabling the object, so why not use FindObjectsWithTag?

I tried but it doesn’t work within this type of function, also it enables the script and take a count of how many of the are in the scene for the sentries I would also like for them to count how many of the Demons are in the scene but thanks thou I think that’s what I will do FindGameObjectsWithTag