Hi! i have a enemy and i want to play his sound, i play his sound when the player is near him, but if the player not move, all time it called, like a Update(), how could I call the sound correctly? Thanks :slight_smile:

if (target != initialPosition && distance < visionRadius)
{
    sound.Play();
    anim.SetBool("Emerge", true);
    anim.SetBool("Hide", false);
    Debug.DrawLine(transform.position, target, Color.blue);
}
else
{
    anim.SetBool("Hide", true);
    anim.SetBool("Emerge", false);
}

And here is my animator and its transitions

// class member
private bool inSight;

// ...
if (target != initialPosition && distance < visionRadius)
{
    if(!inSight)
    {
        sound.Play();
        anim.SetBool("Emerge", true);
        anim.SetBool("Hide", false);
        Debug.DrawLine(transform.position, target, Color.blue);
        inSight = true;
    }
}
else if(inSight)
{
    anim.SetBool("Hide", true);
    anim.SetBool("Emerge", false);
    inSight = false;
}