AI SEE problem

this is my AI script:
what is wrong?

var visionAngle=0.3; // 1 is directly in front 0 is to the side -1 is directly behind
var visionRange = 30.0;
var hearRadius = 10.0;
var thePlayer : Transform;

function findPlayer(){
	var hit : RaycastHit;
	var distanceToPlayer = Vector3.Distance(transform.position, thePlayer.transform.position);
	
	var forward = transform.TransformDirection(Vector3.forward);
	var toPlayer = thePlayer.transform.position - transform.position;
	canSeePlayer = false;
	if (Vector3.Dot(forward,toPlayer) > visionAngle  distanceToPlayer < visionRange){
		if(Physics.Linecast(transform.position, thePlayer.transform.position, hit)){
			if(hit.collider.name == thePlayer.collider.name){
				canSeePlayer = true;
				theTarget = thePlayer;
			}
		}
	}
	
	canHearPlayer = false;
	if(distanceToPlayer < hearRadius){
		canHearPlayer = true;
		theTarget = thePlayer;
	}
	if(!canSeePlayer  !canHearPlayer){ //This has to ultimately be the final else
		function FindNextWaypoint();
	}
}

what is the problem you are having, its kinda hard to find the problem if you dont know what it is

Please be less obscure when posting. throwing 200 lines of code and asking what is wrong with it is not very convenient, and it doesn’t make people want to help you very much. (think of the role on the other foot, would you want people being so obscure with you?)

A seemingly artificial intelligence trying to write an AI script would be my guess…

On close inspection, I see that you’ve created Skynet. We would be doomed, except that there is an AI SEE problem, so Skynet cannot AI SEE us.

What I mean to say is, you’ve got an AI script that you pulled from someone else, and it doesn’t do what you seem to think it should do. How can we help?

this error appear Ahonek:

Assets/Scripts/Control Scripts/AI See Player.js(28,26): BCE0044: expecting (, found ‘FindNextWaypoint’.

what should I do.

And, this FindNextWaypoint, I have aproblem too.
these are the scripts

(there are too many characters in the script, because, I have to attach)
(waypoint actor, have no problems)

please help me!!!

505674–17951–$WaypointMaster.txt (12.7 KB)
505674–17952–$WaypointActor.txt (5.08 KB)

You’re getting that error because by saying “function FindNextWaypoint()” you are trying to define a function.

What should I do?

Programming Basics:

var thePlayer : Transform;

function Update(){
	if(!thePlayer){ // if we currently don't have a player
		thePlayer = FindPlayer(); // go find a player. This expects that the function FindPlayer will return a Transform or null... (Very important)
	}
}

function FindPlayer(){
	if(GameObject.Find("Player")){ // if we can find the player
		return GameObject.Find("Player").transform; // remember, we have to return a transform, not a game object.
	}
	return null; // we HAVE to return something or we will get an error.
}

thank you, it works