- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
MonkeyChunx · Dec 02, 2012 at 10:26 PM ·
aitargeting
Hey I need an AI script for a character noticing nearby characters!
I'm making a game where there is fog and you need to avoid these monsters and i need it so if you go nearby they will chase you, but if you outrun them, they will stop.
Comment
Answer by moinchdog · Dec 03, 2012 at 07:32 AM
have a look at Vector3.Distance.
so try something like
var player : Transform;
function Update () {
var range = Vector3.Distance(transform.position, player.position);
if(range > followDistance) {
//Stop Following
}
else {
//follow
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Assets/MELLE.js(1,15): BCE0044: unexpected char: ';'. 1 Answer
Spray painting 0 Answers
Controlling AI Movement 0 Answers
One player tag, two players, enemy attack who ever is closer? 1 Answer