PDA

View Full Version : How to have "number of" from a list of objects?


aliceguyyowat
10-22-2009, 11:59 AM
I'm trying to have it so that I can make a function that asks if a number of items from a list of objects are within distance of some other object.

For example, I have a variable with a list of penguin objects. They are all 5 meters away from this other object, a snowman for example. I'm going to have all of these penguin objects move forward towards the snowman, however I'd like it so only 3 are within 3 meters of the snowman. There can't be the entire set of penguins within 3 meters.

So how can I put a limit to the number of objects from a list doing something?

x2495iiii
10-22-2009, 01:44 PM
What exactly are you trying to get done? Are all 5 penguins supposed to move towards the snowman and only 3 of them stop (because only those 3 are close enough to the snowman) or are only 3 of them supposed to ever move?

aliceguyyowat
10-22-2009, 02:03 PM
What exactly are you trying to get done? Are all 5 penguins supposed to move towards the snowman and only 3 of them stop (because only those 3 are close enough to the snowman)

^ This.

x2495iiii
10-22-2009, 10:55 PM
Try this:

Loop infinity times
For all all world.penguins one item_from_penguins at a time
If item_from_penguins is at least 3 meters away frm snowman
Item_from_penguins move forward .1 meters duration = 0 seconds
Else
Do nothing

I tested this method with three penguins and a lemur, and it worked pretty well.