User Tag List

Results 1 to 7 of 7

Thread: Always choosing the closest active

  1. #1
    No Products Registered

    Join Date
    Aug 2010
    Location
    Germany
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Always choosing the closest active

    Hello fellow programmers

    I hope this will be quite a simple issue for you to solve. I am trying to simulate simple life forms (represented by several duplicated actives). Their only objective in life is to eat little "food actives" which I spawn at random positions always when one of them gets eaten so that there are always, say, 3 of them.

    Currently all of my little creature actives have a Bouncing Ball movement (I'm aware of the limitations here) and I let them look in the direction of a new food item and walk there to eat it. Of course they now all choose the same object because it's obviously the one that was created recently. How can I change the code so they choose the food active that is closest to them instead of the new one?

    I tried realising this with the Advanced Direction Object which works unless there's more than one creature. Is it even possible for several of them to choose the closest food thingie relative to them?

    [img:left]http://img132.imageshack.us/img132/482/examplequ.th.png[/img]

  2. #2
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Always choosing the closest active

    If you put the code into the object's behaviour, it should work.

  3. #3
    No Products Registered

    Join Date
    Aug 2010
    Location
    Germany
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Always choosing the closest active

    Okay, didn't try that. I don't know what code you would put in there (including the Advanced Direction Object?), but I see if I'll get it done.

    Thanks for your fast answer!

    EDIT: Well, I can't seem to get it to work, at least not with the Advanced Direction Object. Does anyone know an easy method to establish the closest active relative to another active with more than one of both types?

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Re: Always choosing the closest active

    This is an old example:
    http://cid-b1e7ee094271bbda.office.live.com/self.aspx/Public/Seeker.mfa

  5. #5
    No Products Registered

    Join Date
    Aug 2010
    Location
    Germany
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Always choosing the closest active

    Thank you, MuddyMole!

    I'm sure I'll be able to learn a lot from your other examples up on that server as well. Gonna be back when I face new problems

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Re: Always choosing the closest active

    You can try, but bear in mind that a lot of the files were made by other people, and I just edited them a little to fix bugs they were experiencing; also a lot of the stuff is completely unrelated to MMF.

    I really need to sort it all out - I've forgotten what most of the files are myself

  7. #7
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Always choosing the closest active

    Try this code (needs both the foreach and select objects):

    Always:
    -ForEach Object: Start foreach loop for critters
    ForEach Object: On Loop of critters
    -Food: Set alterable value D to distance between food and critter
    ForEach Object: On Loop of critters
    +Select Object: Select "Food" with lowest alterable value D
    -Critter: Look at Food

    It's relatively simple, and shouldn't be too hard to understand.

Similar Threads

  1. Choosing Fonts
    By cajujoe in forum iOS Export Module Version 2.0
    Replies: 8
    Last Post: 9th August 2011, 08:35 PM
  2. Logic help - token choosing
    By arfa in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 30th September 2010, 01:12 AM
  3. which active is closest to?
    By StingRay in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 30th July 2010, 07:13 PM
  4. AI choosing from multiple targets
    By dustingunn in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 21st October 2007, 11:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •