As you can see from the picture, I’ve got AI2blue Script. How can I reset the value in the blue box to it’s default value on trigger?
Active Waypoint : None(Default) —> wpBlue4.
The value changes when my FPC triggers with the waypoints. But I want it to hit the last waypoint tagged “Last Waypoint” and then the values inside the script is reset to it’s default. How can I do it?

Store the initial value in a variable and then when you get to the last waypoint, use the value from this variable to reset the position. If you can post the AI2Blue script (or post a link if it’s publicly available) then I might be able to suggest the exact code you could use.
Thanks so much for helping! =D
AI2blue Script
var speed = 3.0;
var rotationSpeed = 5.0;
var pickNextWaypointDistance = 2.0;
var activeWaypoint: DirectionalWaypointBlue;
private var startPoint : DirectionalWaypointBlue;
// Make sure there is always a character controller
@script RequireComponent (CharacterController)
function Start () {
// Move towards the closest waypoint
//print("Closest waypoint : " + FindClosestWaypoint().name);
print("Moving towards destination.");
FindClosestWaypoint();
var startPoint=FindClosestWaypoint().GetComponent(DirectionalWaypointBlue);
startPoint.isStart=true;
activeWaypoint = startPoint;
Patrol();
}
function Patrol ()
{
while (true)
{
if(!activeWaypoint){
Debug.Log("Destination Reached");
return;
}
var waypointPosition = activeWaypoint.transform.position;
// Move towards our target
MoveTowards(waypointPosition);
yield;
}
}
function MoveTowards (position : Vector3)
{
var direction = position - transform.position;
direction.y = 0;
if (direction.magnitude < 0.5)
{
//SendMessage("SetSpeed", 0.0);
return;
}
// Rotate towards the target
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation(direction), rotationSpeed * Time.deltaTime);
transform.eulerAngles = Vector3(0, transform.eulerAngles.y, 0);
// Modify speed so we slow down when we are not facing the target
var forward = transform.TransformDirection(Vector3.forward);
var speedModifier = Vector3.Dot(forward, direction.normalized);
speedModifier = Mathf.Clamp01(speedModifier);
// Move the character
direction = forward * speed * speedModifier;
GetComponent (CharacterController).SimpleMove(direction);
SendMessage("SetSpeed", speed * speedModifier, SendMessageOptions.DontRequireReceiver);
}
// Find the name of the closest waypoint
function FindClosestWaypoint () : GameObject {
// Find all game objects with tag WPblue
var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("WPblue");
var closest : GameObject;
var distance = Mathf.Infinity;
var position = transform.position;
// Search through all waypoints and find the closest one
for (var go : GameObject in gos) {
var diff = (go.transform.position - position);
var curDistance = diff.sqrMagnitude;
if (curDistance < distance) {
closest = go;
distance = curDistance;
}
}
return closest;
}
DirectionalWaypointBlue Script
static var start : DirectionalWaypointBlue;
var next : DirectionalWaypointBlue;
var isStart = false;
function Awake () {
if (isStart)
start = this;
}
function Start(){
renderer.enabled=false;
collider.isTrigger=true;
// if (!next)
//Debug.Log ("This System requires a minimum of two directional Waypoints, and each one needs its 'Next' varibile assigned", this);
}
function OnTriggerEnter(intruder: Collider){
if(intruder.gameObject.CompareTag("Enemy")){
var ai:AI2blue=intruder.gameObject.GetComponent(AI2blue);
ai.activeWaypoint = next;
}return;
}
function OnDrawGizmos () {
Gizmos.DrawIcon (transform.position, "WaypointBlue.tif");
}
function OnDrawGizmosSelected () {
if (next) {
Gizmos.color = Color.blue;
Gizmos.DrawLine (transform.position, next.transform.position);
}
}