Timing Movement

I cannot grasp the concept of Time in Unity. I do not understand how to use Time.time, although I am beginning to understand Time.deltaTime. Anyway, I have the following code in an AI javascript. The idea is that the Police guy moves from point to point with a set pause in between. I cannot figure out how to use Time to implement the pause. Any suggestions would be appreciated.

var targets : Transform[];
var patrolTargetPause : int = 2;
var moveSpeed : int = 5;

private var shouldPatrol : boolean = true;
private var pause : boolean = false;
private var isAlerted : boolean = false;
private var activeTarget : int = 0;

function Awake() {
	gameObject.transform.position = targets[0].position;
	activeTarget = 0;
}

function FixedUpdate () {
	if(shouldPatrol){
		if(!pause  !isAlerted  shouldPatrol){ //If we should patrol,
			transform.LookAt(targets[activeTarget], Vector3.zero);	//Look at the target
			transform.rotation.x = 0;
			rigidbody.velocity = transform.forward * moveSpeed; //Move
		} else if(pause) {
			if(Time.time > patrolTargetPause){
				pause = false;
			}
		}
	}
}

function OnTriggerEnter (other : Collider) {
	print("Yo");
	if(other.gameObject.tag == "PoliceMoveTarget"){
		print("Yo2");
		pause = true;
		activeTarget++;
		if(activeTarget > targets.length){
			print("Yo3");
			activeTarget = 0;
		}
	}
}

[/code]

So when the enemy first starts out, the pause works, and he moves to the second target. However, upon reaching the second target, he does not pause or look at the third target, but instead moves backwards along the z-axis.

As always, suggestions are appreciated.

So this code would work, but it’s moving the object along the global z-axis rather than the local z-axis. How do I move it along the local z-axis?

var targets : Transform[];
var moveSpeed : int = 5;

private var shouldPatrol : boolean = true;
private var isAlerted : boolean = false;
private var activeTarget : int = 0;
private var follower;

function Awake() {
	activeTarget = 0;
	follower = GetComponent(SmoothLookAt);
}

function FixedUpdate () {
	if(shouldPatrol){
		if(!isAlerted  shouldPatrol){ //If we should patrol,
			follower.target = targets[activeTarget];
			rigidbody.MovePosition(rigidbody.position + Vector3.forward * (0 - moveSpeed) * Time.deltaTime);
		}
	}
}

function OnTriggerEnter (other : Collider) {
	if(other.gameObject.tag == "PoliceMoveTarget"){
		activeTarget++;
		if(activeTarget > targets.length){
			activeTarget = 0;
		}
	}
}

@script RequireComponent(SmoothLookAt)

Alright - I figured it out. Sorry for all the fuss.

var targets : Transform[];
var moveSpeed : int = 10;
var pauseTime : int = 5;

private var shouldPatrol : boolean = true;
private var isAlerted : boolean = false;
private var activeTarget : int = 0;

private var pauseCounter : float;

function Awake() {
}

function FixedUpdate () {
	if(shouldPatrol){
		if(!isAlerted){ //If we should patrol,
			transform.LookAt(targets[activeTarget]);
			rigidbody.rotation.x = 0;
			rigidbody.rotation.z = 0;
			if(pauseCounter <= 0){
				transform.Translate(0, 0, moveSpeed * Time.deltaTime);
			} else {
				pauseCounter -= Time.deltaTime;
			}
		}
	}
}

function OnTriggerEnter (other : Collider) {
	if(other.gameObject.tag == "PoliceMoveTarget"){
		activeTarget++;
		if(activeTarget > targets.length - 1){
			activeTarget = 0;
		}
		pauseCounter = pauseTime;
	}
}