- Home /
Question by
MrCrankyRooster · Jan 19, 2021 at 04:10 PM ·
c#scripting problemgameenemyenemy ai
How do I get enemies to only chase me in certain areas
I'm am currently using a script that works fine at one moment and then the next moment certain enemies don't work while others do - I am confused
void Update()
{
if(Antagonist.attackStage <= PlayerStage.playerStage)
{
transform.position = Vector2.MoveTowards(transform.position, target.position, speed *
Time.deltaTime);
animator.SetFloat("Walking", 3);
}
else
{
animator.SetFloat("Walking", 1);
}
}
Comment
put in Debug.Log to make sure your values are what they should be, it's hard to tell anything from just this script because I don;t know what the stages are or even their variable type.
Your answer
Follow this Question
Related Questions
Is there a better way to tell when enemies are dead? 2 Answers
Help with getting a bool from another script 2 Answers
Unity|C#| Card Game: How to draw a card for each 0.5 secs? 2 Answers
If I duplicate enemies, will their scripts mess each other up? 2 Answers
My script only partially works 2 Answers