How to make good turret AI?

lucario888

  • Posts: 38
So, in a top-down shooter, what can be the decent way to code a turret? I tried to make a radar-type thing with a line rotating over that turret .When that line collides with a player, the turret will shoot there, but then the turret will shoot the walls if the player is detected on the other side of the wall. Any way to prevent this?

Thanks,
Me

Hectate

  • *
  • Posts: 4643
You could use the raycasting extension to test if there is an obstacle in the way of the turret > player line and disregard the player detection if so.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.