How to call a OnTriggerEnter function in a Update function?

How can I get (In Javascript) a OnTriggerEnter function in a Update function for a Enemy AI. This is the code:
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(){

transform.LookAt(Vector3(target.position.x, transform.position.y, target.position.z));

myTransform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);

}

BTW if you know a way to make this code smaller please say it.

Impossible… Because OnTriggerEnter and Update is a different function. So, the function cannot be called in another function. If you want to do that you can make a variable to solve that For Example : if you want to call that Trigger was true. here it this

    var yourVar = false;
    
    function OnTriggerEnter(other : Collider)
    {
    yourVar = true;
    }
    
    function Update()
    {
    if(yourVar)//if yourVar is true
    {
    //do something in here
    }
    }

Shinxs you need to think in form of events.

Sure you can move the rocket or whatever in Update and if that move resulted in a collision with a trigger, then OnTriggerEnter will be called and you explode it there.

You do not need to check if a collision happened in Update. You can of course do it i.e. with RigidBody SweepTest() SweepTestAll() but you do not have to.

Anyway for such stuff to work both game objects need to have a rigidbody and collider attatched and one has to be flagged with IsTrigger if you want to use OnTriggerEnter.