Enemy Attack at Certain Range to Player?

JoshKahaneJoshKahane Member Posts: 470
edited November -1 in Working with GS (Mac)
Hi

I was wondering. How can I make it so that for example at a certain range of my choice the enemy does a certain action (attack is my plan) when it comes within range of my player. So say the enemy is at a distance so that he is seen on screen, how can I make it attack when this happens?

Thanks.

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    try using the magnatude function, that should work, it determins the range between two points. you can read about it in the Wiki.
  • JoshKahaneJoshKahane Member Posts: 470
    Hmm ok cool I'll check it out, thanks Mulcahy.
  • JoshKahaneJoshKahane Member Posts: 470
    Ok after taking a good look at it it seems I can't figure it out. Could someone take a look for me please? And even better than an explanation would be just a quick demo that shows number two actor moves to number one actor when in range. Thanks.

    Also, any attributes I need to make (for example player x and y, (Im guessing, would I need them?)) won't I need to make them for every single enemy or just once? I want to have several enemies but all react to the distance individually.
  • JoshKahaneJoshKahane Member Posts: 470
    Ok. What I have done, instead of using magnitude (not sure which is better for performance) but I have created an invisible actor larger than the player which is constrained to the players x and y position so it is always over him. Now when the enemy collides with this large actor around the player they move to them.

    Now I just have to work out how to have him stop running and attack. :)
Sign In or Register to comment.