- Home /
Make the Enemy animation stops
Hey all, i have a problem, i made an enemy, animations, and i wanna stop the animation when the enemy is near or collide de player.Here's my code:
var Player : Transform;
var MoveSpeed = 4;
var MaxDist = 10;
var MinDist = 5;
function Start ()
{
}
function Update ()
{
transform.LookAt(Player);
if(Vector3.Distance(transform.position,Player.position)
>= MinDist){
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
if(Vector3.Distance(transform.position,Player.position)
<= MaxDist)
{
}
}
}
This is my code, and my animations are on "ping-pong" cause thay are a 3 animations, on chest, on legs, and on the arms. and i want to make these animations stop on collide or if is near the player or just play another animation.
like my name, i'm brazilian ahuehaeuhuaehuaeheuah
serious, help me
hu32.jpg
(20.4 kB)
Comment