I'm working in a single AI for my game, so the enemies will dodge rocks and other obstacles. So I'm making a check to see if the path ahead is blocked. If it is, it opens the angle in 20 degrees and checks in both directions, and goes to the one that is unblocked. If both are blocked, then it picks one randomly. Once it is in the new path, it calculates the angle to the player and starts to turn again.
But there's a problem: sometimes instead of turning like 45 degrees to reach the player, the enemy turns 315 degrees. Since I check if the new angle is smaller or larger than the new angle and adjust it, I believe this is a problem with angles above 360 or under 0. Should I use a mod 360 to adjust the angle? I always hear Mod should be used rarely, so is there any other way to do this?
Thanks in advance.
But there's a problem: sometimes instead of turning like 45 degrees to reach the player, the enemy turns 315 degrees. Since I check if the new angle is smaller or larger than the new angle and adjust it, I believe this is a problem with angles above 360 or under 0. Should I use a mod 360 to adjust the angle? I always hear Mod should be used rarely, so is there any other way to do this?
Thanks in advance.