so after loads of R&D Ive found that I can have more than one enemy on the map, based on the same sprite,
not in groups, like I used to use, but by Spread value,
so ive programmed a patrol routine in, based on collisions with other sprites,
also added , a chase routine so when the player gets too close the badguy chases after them, Ive used the spread routine to add detectors to the bad guys, so they move like the player, (Yay!) all works so far,
I re-add another bad guy on patrol, and BANG it all stops working,
if I use the spread value in the chase routine(checks players distance by Pytagororas) but then the other bad guy never gives chase when its time,
also if I take the Spread value out of the distance check, both the enemys chase when you get close to one of them,
I feel like I should be using a for i loop, to check distance for all the bad guys, but im not sure how to do it in MMF..
anyone know what im talking about, and can anyone help ?
Time for a Sexy Party!
DaVince This fool just HAD to have a custom rating
30th September, 2007 at 10:31:39 -
I don't get how you're trying to use Spread value here. Spreading a value is intended to make each sprite unique by giving each instance a new value.
Spreading a value of 0 will make sprite 1 have the value 0, sprite 2 have the value 1, sprite 3 have the value 2...
If you spread a value of 234, sprite 1 will get a value of 234, sprite 2 will get a value of 235, and sprite 3 will get a value of 236. As you see, the number you can pass onto it is just an offset.
I think what you think Spread Value is for is "change all enemies' Alterable Value #s to the following", but that's not how it works. To do that, you just use "set alterable value # to #" without narrowing down for who it counts.
To properly store the distance:
- Start of frame (or on creation of new enemy):
spread value 0 in alterable value of sprite
Start loop "check distances" (amount of enemies) times
- On loop "check distances"
AND alterable value of sprite = LoopIndex("check distances"):
calculate pythagoras, store it in another alterable value of sprite
This will make each enemy hold their own unique ID (using Spread Value), and their own distance calculation (using the loop and loop index).
You can make more events like the last one to check if that enemy should be chasing now, too.