Proximity Function for follow/attack -
09-22-2009, 09:34 PM
Create a new method under World, and name it something like If enemy follows. THen, at the bottom of the screen, there are little tabs. Click and drag the loop one (light blue) onto your If enemy follows method. THen, drag a green If/Else tab into the loop. Set the true/false to true. Make the loop repeat infinity times. (Note: if that doesn't work or causes an error, try a recursive call at the end{put the same method you are working on into that method}). THen, take the "If character is <threshold> from <object>" function from the side menu and drop it onto the true part of the If/Else thing. Select a suitable distance (5 or 10 meters, depending on the size ratio of your game) and select "from: Enemy". Then, in the 'then' blank that says do nothing, put in an animation and attack program for that particular enemy. Copy it and change the Enemy to Enemy 2 or something like that for every reference and put it in the blank 'else' box in the first one. Repeat as neccesary.
|