Hi, can you help me? I need a way to turn the enemy around. The enemy must walk towards the player and obviously must be turned towards him, on all sides. is a 2D game.
I have tried with this code, but it is very slow
void flipAnimazion(){
if(player.position.x >= 0 || player.position.y >= 0){
animazion.SetBool("run", true);
myTransform.localScale = new Vector3(player.position.x +
player.position.y < 0 ? 0.1487581f : 0.1487581f, 0.1544615f,
0.155289f);
} else if(player.position.x < 0 || player.position.y < 0 ) {
animazion.SetBool("run", true);
myTransform.localScale = new Vector3(player.position.x +
player.position.y > 0 ? 0.1487581f : -0.1487581f, 0.1544615f,
0.155289f);
} else {
animazion.SetBool("run", false);
}
}