fastloop question

3 replies [Last post]
hairybiker's picture
User offline. Last seen 18 weeks 5 days ago. Offline
Joined: 12/18/2009
GBPs: 331

hi is it possible to use a behaviour on an active within a loop index.

what im after is enemy there are three of them in one fast loop: well its realy just the one copyed and spreading the value so each one has its own value.

i want each one to behave only if it is within a set distance of the player.

I.e player close to enemy. Enemy change to alerted

Currently what happens is all the actives change to alerted.

im missing something.

could you help please and thanks

Cecil's picture
User offline. Last seen 16 weeks 6 days ago. Offline
Joined: 11/07/2008
GBPs: 1468

you shouldnt have to use a loop at all, and is an unnecessary waste of cpu. you need to check for 'enemy is close to player' NOT 'player is close to enemy'. that way the instance of the enemy is chosen in the conditions and any events specific to that object type should only affect THAT instance. the way you are describing, mmf has no idea what instance you want to apply your actions to so it just applies them to every instance. The same is true for objects in a group.

Cecil's picture
User offline. Last seen 16 weeks 6 days ago. Offline
Joined: 11/07/2008
GBPs: 1468

as an example. i have 2 actives. my 'player' and multiple 'enemy'.

my player is moved left and right with the arrows. the enemy has two animations. normal and alert.

if do the following (the way you described doing it. 'player is close to enemy'):

+always
-set animation of 'enemy' to 'normal'

+X Position of 'player' >= ( X('enemy') - 25 )
+X Position of 'player' <= ( X('enemy') + 25 )
-Set Animation of 'enemy' to Alert

i get all the enemies being alert even if the player is only within 25 pixels horizontally of one of the enemies.

now if i do this (the way i described it. 'enemy is close to player'):

+always
-set animation of 'enemy' to 'normal'

+X Position of 'enemy' >= ( X('player') - 25 )
+X Position of 'enemy' <= ( X('player') + 25 )
-Set Animation of 'enemy' to Alert

i only get the one enemy that is within 25 pixels horizontally of the player being alert, while all others are still normal.

as a general rule, you should be making comparisons from the perspective of the object you want to apply actions to. enemy is vague. player is specific. if you compare something specific to something vague, expect the results to be vague. if you compare something vague to something specific, expect the results to be specific.

make sense?

hairybiker's picture
User offline. Last seen 18 weeks 5 days ago. Offline
Joined: 12/18/2009
GBPs: 331

thnks for the help i recently changed it to your answer and i didnot understand why it worked and now reading your post i do many many thanks.

Thats me all over everything back to front i am still a newbee and eager to learn.

Thank you