A "special" follow script?

Hello, I am pretty new to Unity.

I did search around a bit, and I did manage to find a script that would make an object follow me.

However, for what I need to do I want to change this script a bit.

I’d like to make it so that while the enemy spawns, he is a passive enemy that won’t chase you, but when you grab an item, he will get aggressive and will hunt you down.

I am sorry if this is a really simple thing to do…

The code is below.

var target : Transform;
var moveSpeed = 3;
var rotationSpeed = 3; 
 
var myTransform : Transform; 
 
function Awake()
{
    myTransform = transform; 
}
 
function Start()
{
     target = GameObject.FindWithTag("Player").transform; 
 
}
 
function Update () {
    myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
    Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
 
    myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
 
 
}

You can use Rain Indie to do that. With the behavior tree system you can create an AI, which waits for the player to do something and after start to chase him untel death.