User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Creating objects that don't overlap

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Creating objects that don't overlap

    I'm creating objects inside a fastloop and need to test their position against other copies of the same object to make sure they don't overlap. It is set up like this:

    +On loop "CreateObj"
    -Create Obj at 0,0
    -Set Obj X to Random(320)
    -Set Obj Y to 32
    -Set Flag 1 to ON

    +Always
    -Spread value 0 in ID(Obj)

    +Obj overlaps Obj
    -Start loop "CheckObjPos"

    +On loop "CheckObjPos"
    +ID(Obj) = Index of "CheckObjPos"
    +Obj overlaps Obj
    +Flag 1 is ON
    -Set Obj X to Random(320)

    +On loop "CheckObjPos"
    +ID(Obj) = Index of "CheckObjPos"
    +Obj overlaps Obj (NEGATE)
    -Set Flag 1 OFF

    I'm not sure if there is a problem testing an object against itself, but I can't seem to get the code inside the last fastloop to fire. Any suggestions?

    Thanks in advance,

    Mobichan

  2. #2
    Clicker Multimedia Fusion 2 Developer

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

    Re: Creating objects that don't overlap

    Yes, "ID(Obj) = Index of "CheckObjPos"" restricts MMF to only one "obj", then "Obj overlaps Obj" can only test the "obj" against itself.

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    Any suggestions on how to create a new object at a random position and if it overlaps an already existing object (a copy of the same object) have it choose another random position? And in case the new position also overlaps, how to keep choosing random positions until it isn't overlapping any copies?

    Mobichan

  4. #4
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    How about dividing your area into grids and using an array to keep track of what cells are taken or not?

  5. #5
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module
    RickyRombo's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere between here and there
    Posts
    3,167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    Or you could have a second temporary object placed at the xy just to test for the overlaps...

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    I tried the secondary detector object method. The problem I run into is that since all the objects in the overlap condition are copies, it makes it hard to distinguish which object is the one I just created and which objects were already there. I think I might try keeping an array of the objects positions and test each newly created object against the array.

    Sheesh, I never thought it would be this complicated.

  7. #7
    Clicker Multimedia Fusion 2

    Join Date
    Jun 2007
    Location
    Suffolk, UK
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    Quote Originally Posted by mobichan
    I tried the secondary detector object method. The problem I run into is that since all the objects in the overlap condition are copies, it makes it hard to distinguish which object is the one I just created and which objects were already there.
    In the event where you create your new object, you could store it's fixed value in an alt value of the detector object. Then by comparing an objects fixed value against the one stored in the detectors alt value, you'll know if it's the newly created one or not

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    I did try that, but the problem is that the newly created object will always return true to an overlap check with the detector. So any call to destroy "Obj" will destroy the newly created one AND the existing object that are overlapped by the detector. I would want to destroy the newly created one ONLY. The only selection I can make is the object that is NOT the newly created one. And I can't figure out how to make that work for me in this case.

  9. #9
    Clicker Multimedia Fusion 2

    Join Date
    Jun 2007
    Location
    Suffolk, UK
    Posts
    435
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    Ok, well maybe try approach the problem the other way round instead.
    Rather than creating the object then testing for an overlap, place the detector where you want the new object, test that for an overlap and if it doesn't overlap only then create the new object.

    Edit:
    Quote Originally Posted by mobichan
    the newly created object will always return true to an overlap check with the detector
    not if you compare the fixed value in the conditions.
    By adding a condition: Fixed value of object does not equal alt value a of detector
    the new object gets omitted from the selection

    Quote Originally Posted by mobichan
    The only selection I can make is the object that is NOT the newly created one. And I can't figure out how to make that work for me in this case.
    The fact that one was selected would be all you need. Don't do anything to it directly in that event, instead set a flag on in the detector. Then in another event use :
    * detector flag is on
    + fixed value of object equals alt value A of object
    = delete object
    = set detector flag off
    So because the overlap check was true, just set a detector flag and then if the flag is on, identify your new object and delete it.

  10. #10
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,281
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Re: Creating objects that don't overlap

    Thanks for the idea. I wasn't seeing it from that perspective. A very elegant solution.

    I actually found another workaround: Make an animation on the object that acts as a detector. On creation, the object is set to that animation. Then detect for overlap. If no overlap, then change the animation to one with the object as it normally appears. If it overlaps and the animation = "detector", then destroy it.

    Thanks for all the help,

    Mobichan

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Objects can't collide or overlap if they are on different layers?
    By SuperDisk in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 10th April 2013, 10:46 AM
  2. creating objects without overlap
    By SolarB in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 12th July 2012, 02:48 PM
  3. overlap of 2 objects with the same qualifier
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 8th April 2009, 03:28 PM
  4. Select two objects that overlap for Event
    By Simion32 in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 13th April 2007, 04:58 PM
  5. Two objects overlap. Delete only one.
    By Dines in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 8th April 2007, 11:29 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
  •