Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How to have "number of" from a list of objects?
Old
aliceguyyowat
Guest
 
Status:
Posts: n/a
Default How to have "number of" from a list of objects? - 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?
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 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?


(')>
   
Reply With Quote
Old
aliceguyyowat
Guest
 
Status:
Posts: n/a
Default 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.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 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.


(')>
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.