- Home /
Question by
HyperNovaGames · Jan 22, 2014 at 07:35 PM ·
collisionupdate function
Colision And then Function update Help
I created a script that Says when you collide with an object Have the Follower follow the player (Leader) and then have it be updating all-ways. Here is the script.
var leader : Transform;
var follower : Transform;
var speed : float =5;
//when it collides with the object (a portal or anything)
function OnTriggerStay(theCollider : Collider)
{
if(theCollider.gameObject.tag == "Player");
}
function Update(){//When the trigger is started then fillower start to go to player
follower.LookAt(leader);
follower.Translate(speed*Vector3.forward*Time.deltaTime);
}
PLEASE HELP IF YOU CAN!
Comment
Best Answer
Answer by fafase · Jan 22, 2014 at 07:38 PM
You need to tell what is your issue if you need help.
In your case:
follower.Translate(speed*Vector3.forward*Time.deltaTime);
this is translating the AI in the Vector3.forward direction which is the world forward but you want to move in the transform.forward direction
follower.Translate(speed*transform.forward*Time.deltaTime);
Note that you should use a character controller or your guy will got through objects regardless the colliders.
Your answer
![](https://koobas.hobune.stream/wayback/20220613131142im_/https://answers.unity.com/themes/thub/images/avi.jpg)