User Tag List

Results 1 to 6 of 6

Thread: "Create [x] at 0,0 from nearest [y]"

  1. #1
    No Products Registered

    Join Date
    Apr 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "Create [x] at 0,0 from nearest [y]"

    See the thread subject. That's what I need to do, and I can't work out any way to do it!

    To elaborate a little:

    * [x object] collides with [y qualifier]
    |___*Destroy [x object]
    |___*Create [x object] at 0,0 from nearest [z object] from this event.

    Please note that:
    * There are tons of objects with [y qualifier]
    * [z object] is replicated many times throughout the level.

    I can't work out how to do this though, as MMF2 doesn't seem to have a 'nearest' action. I'm sure it's just a matter of using expressions and values correctly, but I can't think how for the life of me.

  2. #2
    No Products Registered

    Join Date
    Feb 2007
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: "Create [x] at 0,0 from nearest [y]"

    You need to spread a value through the objects first. Then to pick each object to test, fastloop through them comparing their spread value to the loop index. To check the distance use the "advanced direction" object. See it's example files on how to do that.


  3. #3
    No Products Registered

    Join Date
    Apr 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: "Create [x] at 0,0 from nearest [y]"

    Thanks man!

    Just three things I don't understand:

    * How does spread value work? Does it spread it from top-left to bottom right, for example?
    * What's the difference between a loop and a fastloop?
    * The Advanced Direction Object only seems to compare distance in terms of less than or equal to. How can I just say 'shortest available distance'?

    Thanks!

  4. #4
    No Products Registered

    Join Date
    Feb 2007
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: "Create [x] at 0,0 from nearest [y]"

    The Advanced Direction Object only seems to compare distance in terms of less than or equal to. How can I just say 'shortest available distance'?
    You need to enter 1, 2, 3 etc. 1 being closet, 2 being second closest etc.

    Did you look at Andos example? It shows how to find the nearest object.



  5. #5
    No Products Registered

    Join Date
    Dec 2006
    Posts
    1,332
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: "Create [x] at 0,0 from nearest [y]"

    1. Spread Value gives a different number for each instance of an object as an alterable value. I'm not quite sure in what order. I think by created first, but I don't know about multiple instances at the start of the frame.

    2. A loop is what MMF2 does with normal events. A fastloop is a loop that will loop given events a specified amount of times in rapid succession.

    3. There is an example that comes with the Advanced Direction Object that does exactly what you want.

    Quote Originally Posted by MrMan
    You need to enter 1, 2, 3 etc. 1 being closet, 2 being second closest etc.
    And it is number 0 for the closest object in the Advanced Direction object, not 1.

  6. #6
    No Products Registered

    Join Date
    Apr 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: "Create [x] at 0,0 from nearest [y]"

    Thanks guys! Hit a real snag, though.

    The test level I've got set up looks like this:

    Code:
    |                 |
    |            _    |
    |           | |   |
    |           | |   |
    |  _     ___| |___|
    | | |   |
    | | |___|
    The middle and right pits have water in, but not to the top. What's SUPPOSED to happen is, when you pour water (made of lots of small dots that look like a stream) into any of the pits, it fills the water up to a certain level, at which point it fills no more. Then, when you pour water into a pit that's already full, it finds the nearest 'overflow' object and makes a stream of water come out of there instead.

    All of that works just fine!

    But the problem occurs when you pour water into the rightmost pit, and the middle pit isn't full. What SHOULD happen is:

    * Rightmost pit fills
    * Water overflows into the middle pit
    * Middle pit fills with the overflowing water from the top pit
    * Middle pit, in turn, overflows into left pit, causing the water to leave the play area.

    What REALLY happens is:

    * Rightmost pit fills
    * Water overflows into the middle pit
    * Middle pit fills with overflowing water from the top pit
    * Water from the filled middle pit, instead, spawns from the overflow point for the rightmost pit, meaning that even if you stop pouring the water, it keeps flowing around into itself in a highly unrealistic loop.

    As you can imagine, this is really frustrating. The worst part is, it's not just when you're doing something that complicated: If you fill one pit entirely, stop pouring the water and wait a bit, and then start pouring it into another pit, it'll STILL generate water from the overflow point for the first pit you filled!

    I'm so close to having this whole 'water' thing cracked after days and days of head-scratching, this is pretty much the last obstacle facing me. Does anyone know what I might be doing wrong?

    For reference, here's the events I have in place (minus the ones that already work):

    Please note that qualifier 3 is the 'still' water that fills up. It had to be a lot of unique objects, so I used a qualifier. The alterable value B of qualifier 3 = 1 event is just to differentiate still water that has already 'filled up' from that that hasn't.

    Code:
    * Every 00"-01
    |__* Add 1 to alterable value B of 'falling water'
    
    * Alterable value B of 'falling water' = 150
    |__* Destroy 'falling water'
    
    * Alterable value B of 'qualifier 3' = 1
    + Collision between 'falling water' and 'qualifier 3'
    + Alterable value A of 'falling water' = 0
    |__* Set alterable value A of 'falling water' to 1
    |__* Set alterable value B of 'falling water' to 148
    |__* Start loop "overflow" 1 times
    |__* Set alterable value C of 'falling water' to 1
    
    * On loop "overflow"
    + Alterable value C of 'falling water' = 1
    |__* Advanced Direction Object: Find distance and fixed of 'overflow object' to 0,0 from 'falling water'
    |__* Set alterable value C of 'falling water' to 2
    
    * On loop "overflow"
    + Fixed value of 'overflow object' = GetFixedObj("Advanced Direction Object", 0)
    |__* Create 'falling water' at 0,0 from 'overflow object'
    Phew, sorry about the long post. I've tried and tried but nomatter how much I look at my code, I can't work out what I've done wrong. Can anyone see it?

Similar Threads

  1. Distance and Nearest Object
    By Hydra in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 13th February 2013, 01:06 AM
  2. Getting Nearest Enemy
    By MangoMan in forum Multimedia Fusion 2 - Technical Support
    Replies: 19
    Last Post: 21st December 2011, 03:04 PM
  3. Detecting Nearest object?
    By PandaExplosion in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 27th July 2011, 03:37 PM
  4. Going to object that is nearest?
    By Solgryn in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 19th July 2009, 08:24 PM
  5. Get details of nearest object
    By Dines in forum Extension Development
    Replies: 9
    Last Post: 29th May 2008, 04:37 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
  •