Compiler error with A.I movement Script

So I have a script that basically makes the enemy object look at the player, and move towards the player if they are a certain distance away. However, I am getting a compiler error saying that “An instance of type ‘UnityEngine.CharacterController’ is required to access non static member ‘Move’.” The prefab that this script is attached to has a CharacterController component, so I am not sure what is wrong. Here is the script:

//Inspector variables
var target : Transform;//Target object of the enemy, i.e. "Player" object
var Speed : float;//Speed of the enemy object
var maxMoveDistance : int;// Max Distance allowed between enemy and player before enemy moves towards player
var minMoveDistance : int;//Minimum distance from target before enemy will stop moving

@script RequireComponent(CharacterController)

function Update () 
	var controller : CharacterController = GetComponent(CharacterController);
	var dist = (Vector3.Distance(transform.position,target.position));
	if (dist > maxMoveDistance && !(dist < minMoveDistance))
		var dir : Vector3 = target.position;
		CharacterController.Move(dir * Speed);
		//transform.position = Vector3.MoveTowards(transform.position, target.position, Speed);

You need to use GetComponent; without that you can’t just write “CharacterController.Move” if Move isn’t a static function.


CharacterController.Move(dir * Speed);

to this and try again

controller.Move(dir * Speed);