Targeting Issue

Hi

I am trying to write a simple targeting code and this one is the last one I came up with. I tried to use other things but same problem probably. Here is the code:

var myTarget = GameObject;


function Update () {
	if ( ! myTarget ) {
		var radarTarget = GameObject.FindWithTag ( "Friend" );
		
		if ( ( radarTarget.transform.position - transform.position ).sqrMagnitude < 10000 ) {
			myTarget = radarTarget.gameObject;
		} 
	}	else {
			print ( "Fire" );
		}

}

Have Fun
Bahadir Boge

Error Message:

Assets/Custom Assets/Scripts/TurretAI.js(9,48): BCE0022: Cannot convert ‘UnityEngine.GameObject’ to ‘System.Type’.

var myTarget = GameObject;

To expand on that a little, you should have a colon in the declaration instead of an equals sign:-

var myTarget: GameObject;

Check out my post in the showcase forum named (script) targeting IFF. It’s on the second page I think. That should get you started.

Thanks for the heads up