User Tag List

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

Thread: 2d Elastic collision of duplicate objects -no exts

  1. #1
    No Products Registered

    Join Date
    Sep 2007
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2d Elastic collision of duplicate objects -no exts

    Hello. This is an example of how one can handle collision between round objects in a 2d coordinate system. It does perfectly elastic collisions, and handles 360 degree collisions and floating point coordinates.

    The novel method in this example is that an infinite amount of duplicate objects can be spawned and accounted for. It is usually very difficult to handle cases where 2 duplicate objects are compared to each other in an event condition but need separate actions depending on each object. In MMF, this can be solved in two ways:


    1. Spread a value 0 into an Index value of the ball objects. Iterate a nested loop i and i2, where i2 only executes if >i to remove redundant cases. On each i2 execute, plug the values (using 2 separate events to qualify Ball("i") and Ball("i2")) into a holder object. Perform calculations if distance between Ball("i") and Ball("i2") < their combined radii. This is the more complex collision detection, and has an exponential cost per MMF loop the more balls exist on frame.

    2. Let MMF handle the collision events using fine detection, and use these red events as a "breaker" sequence. To plug the values of each object in a collision, a secondary value 1 is spread in the CollisionIndex of the qualified balls. Inside the breaker sequence, we can plug the values into our holder object and perform the vector calculations before putting the result back into our 2 collided balls. This method is what is used in our example.

    Calculating the vectors themselves is done using a relatively common method. In our example, X and Y deltas are used to change the balls' positions on each display loop. When a ball collides with a rigid body, itself, or the delta forces otherwise change, a new vector is calculated by converting the delta values into polar coordinates. In the ball-to-ball collision method, we operate on these polar coordinates before converting them back to the delta values (which are used for the practical movement).




    The primary advantage to this example is that no non-clickteam extensions are used in it. Because of this, it should be portable to any platform which MMF's export can support. I've also added a shader to this example to give an idea of what you can do with the duplicate objects. Once the method is understood, the complexity of the code is reduced considerably, and can be expanded/reused to fit the developer's needs.

    Feel free to let me know if you found this example useful.
    Attached files Attached files

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    +1, great example and very nifty coding
    Working as fast as I can on Fusion 3

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,730
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    +1 for Nobuyuki. This would be excellent for snooker and pool.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module

    Join Date
    Sep 2006
    Posts
    311
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    Quote Originally Posted by Nobuyuki
    and floating point coordinates.
    AWESOME and very useful! Thanks! Now the bouncing ball movement is perfect!

  5. #5
    Clicker Fusion 2.5 Developer
    ChrisStreet's Avatar
    Join Date
    Jul 2006
    Location
    United Kingdom
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    I didn't know you were still around Nobuyuki, or that you still used MMF

  6. #6
    No Products Registered

    Join Date
    Jun 2006
    Posts
    1,630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    Great work! Can this be used to make a pool game?

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,730
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    Should be able to use this for pool or snooker Bruto

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  8. #8
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    Quote Originally Posted by ChrisStreet
    I didn't know you were still around Nobuyuki, or that you still used MMF
    He was devoting his time to this here pure awesomeness
    Working as fast as I can on Fusion 3

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    DaveC's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Australia
    Posts
    2,114
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    thanks!! this is extremely useful.. I think it's safe to say I would NEVER have thought of this.. there needs to be an easier way for MMF2 to handle collisions of duplicate objects, but this will do for now.

  10. #10
    No Products Registered

    Join Date
    Jul 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: 2d Elastic collision of duplicate objects -no exts

    Thankyou to Nobuyuki for this beutiful code.
    How hard would it be to add a maze like collidable backdrop obsticle to this demonstration? I see that the walls are set by coordinates. In the example of pool what information would the cue contain? Could the nessesary values be input by mouse movement alone?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Duplicate objects/enemies and have them each behave on their own? I know theres a way
    By edman3d in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 23rd December 2012, 10:58 AM
  2. Populating duplicate active objects from an array
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 25th June 2012, 01:06 PM
  3. how do i make all duplicate objects face...
    By solarstorm in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 21st May 2011, 09:40 PM
  4. Order of duplicate objects.
    By Livingstone in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 19th May 2010, 05:20 AM
  5. Problem with picking duplicate objects
    By Simon in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 28th March 2009, 01:41 AM

Posting Permissions

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