how to make the enemy shoot when it sees the player

bad_dawgbad_dawg Member Posts: 38
edited November -1 in Working with GS (Mac)
hi guys..im working on this top down shooter i can make the enemy actor rotate towards the player actor..but i dont know how to make the enemy actor shoot when it sees the player actor(when the player is close enough for the enemy actor to be able to shoot)...please help

Comments

  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    You Need to calculate the distance, and when distance is lower than a number, he shoots.
    Search in site wiki for magnitude (Distance)
    Cheers.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
  • OkyshoOkysho Member Posts: 158
    I had the same issue, Magnitude is the way to go subtract the player's X from the enemy's X and the player's Y from the enemy Y and that's the formula. Store that into an attribute within your enemy and call that "distance from" You're pretty much home free from there. Rule > attribute "distance from" is less than... say... 500, then KILL KILL KILL!!! I mean... spawn bullet...
    ^.^
  • bad_dawgbad_dawg Member Posts: 38
    THANKS A LOT GUYS!!!!!
Sign In or Register to comment.