User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 19 of 19

Thread: Pushing two objects away from each other

  1. #11
    No Products Registered

    Join Date
    Jul 2006
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    lol I'm home sick with a 103 degree fever... I took motrin so its ok right now...

  2. #12
    No Products Registered

    Join Date
    Oct 2006
    Location
    France!!
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    Hi!
    I've been working a long time on this problem without finding a perfect solution.
    Here's an example which works until there are more than 2 simultaneous overlappings ('cause it works with 2 counters = 2 objects)...
    I wish it could help you!

    http://www.yousendit.com/download/cTonTt9np3l5TA%3D%3D

    If somebody could improve this method, i'm interested!!

    PS : As i'm french the comments in the .mfa are quickly translated so : sorry for my english!! [grin]

    BenJ

  3. #13
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    Okay well I've been using a method for detecing similar objects.

    You will need one detector object (possibly more depending on movement) and then you have your two or more duplicates. Here is an example of how you apply them:

    To simplify the example let's say that the zombies only move left at 1 pixel at a time. The detector is for the zombies left side. We only need 1 detector even though we have multiple zombies, because we will use loops.

    Always run a loop for the number of zombies that there are

    On loop "zombie"
    and zombie Id = loopindex("zombie")
    + Set the detector's x to the zombie's current x position - 1
    + set the detecotr's y position to the zombie's Y

    On Loop "zombie"
    and zombie Id = loopindex("zombie")
    and detector is not overlapping a backdrop
    and detector is not overlapping a zombie
    + Zombie.x = Zombie.x - 1

    //Here is the code that will be able to find when one zombie overlaps the other, and pick the rightmost zombie. Note how I have not used 'and zombie Id = loopindex("zombie")'

    On Loop "zombie"
    and detector is overlapping a zombie
    + Set Detector's Flag 0 to on

    On Loop "zombie"
    and detector flag 0 is on
    + Detector.x = Detector.x + 4

    // The detector now moves 4 pixels to the right, so it will be overlapping the zombie which is trying to move right.

    On Loop "zombie"
    and detector is overlapping a zombie
    and detector flag 0 is on
    + (Do something here, stop the zombie if you want)
    + Detector.x = Detector.x - 4
    + Detector.flag 0 = off

    That's the end of the code. So basically what happens is you run a loop through all the zombies, putting the detector in front of them. As soon as the detector overlaps a zombie, you know that a collision between two zombies has occured. In this instance you move the detector 4 pixels to the right, so now it will be overlapping the zombie which did the colliding. Since the detector is only overlapping one object we are able to isolate it and apply actions to it.

    I can make a quick example if you want me to.



  4. #14
    No Products Registered

    Join Date
    Aug 2006
    Location
    Westcountry, UK
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    If you a using a pathfinding extension then whilst looping the zombies put the tile that the current zombie is walking to as filled and the one it is on as empty.

    This will mean that the zombies can't walk through the solid tiles and so in turn they can't walk on each other

  5. #15
    No Products Registered

    Join Date
    Jul 2006
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    wow nice code ninja... btw anyone else here get influenza? I was the first patient this year that got it in my area... Stupid virus lasts for 5 days!

  6. #16
    No Products Registered

    Join Date
    Jul 2006
    Location
    Texas
    Posts
    1,225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    I've got a better idea for the detector system. It is just like ninja put. It will be a rectangle roughly that size of the zombie (when the zombie is not rotated), and then it will put the detector on a zombie, and detect if there is a zombie overlapping it that is not the zombie it is supposed to be on, then, if there is an overlap (and not overlapping a backdrop, it will get the angle between the zombie and the detector, then it will move the zombie away about 2 pixels. If that movement puts the zombie into a backdrop, it moves it back to its previous location, and moves on to the next zombie in the loop.

    If comparing angles is too slow, I'll just compare along each axis.

    I'm not using a pathfinding extension, I'm using a cheap method that detects if the zombie is on a collision course with an obstacle, and rotates it away from the obstacle. It works surprisingly well.

  7. #17
    No Products Registered

    Join Date
    Jul 2006
    Location
    Texas
    Posts
    1,225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    Yesssss!!!!! I just tried my method that I told about above, and it worked!!!!!

  8. #18
    No Products Registered

    Join Date
    Oct 2006
    Location
    France!!
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    nice!
    Could you post an example to show us how exactly you do that???
    Thanks

    Ben

  9. #19
    No Products Registered

    Join Date
    Jul 2006
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Pushing two objects away from each other

    Glad you could fix it. Like Phenix said... Could you post an example of how you did it?
    Share your method with your friends!Barbie Girl(man I hate that commercial...)

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Pushing a Box
    By FlinkGigitty in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 7th August 2010, 08:39 PM
  2. Pushing blocks?
    By Mdsx in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 13th December 2009, 07:08 AM
  3. Pushing objects?
    By Robin_Manager in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 6th September 2008, 05:48 PM
  4. Pushing Objects
    By Gigagambit in forum The Games Factory 2 - Technical Support
    Replies: 5
    Last Post: 26th January 2008, 11:45 AM
  5. Pushing Against Walls
    By DavidN in forum File Archive
    Replies: 3
    Last Post: 10th September 2006, 09:40 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
  •