User Tag List

Results 1 to 6 of 6

Thread: A few Box2D questions...

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    A few Box2D questions...

    Okay so I've been playing around with the Box2D testbed the past few days but I still can't seem to wrap my head around a few things...

    1. How do I check collisions of certain bodies/objects? For example, a Hero object and a Block object. Do I have to do the "register collisions" thing? What would I put there? Does "type 0" represent everything that doesn't have a type, or is it just a way to label a type?

    From what I can make out, I first need to register collisions for the various types, and then I need to actually set the various types to particular bodies. Right? Do they have to be in that order? Do they have to be above other events or below? This is where I get confused.

    2. Also there are a whole ton of different collision events... what does what? I looked up tutorials which seemed to help, but they don't translate to the MMF extension. Could someone run through the list of collision events and explain them? What is the difference between "on collision begins" "on contact point add" and "body is touching another body"? Don't they all do the same thing?

    I'm trying to figure out how to detect when the player object lands on top of another specific object (or hits it from underneath) or whatever.

    3. Will Phizx Box2D work with the flash exporter? If not now, are there any plans to make it work?

    Thanks in advance

  2. #2
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: A few Box2D questions...

    1. First, give both bodies a type, it can be the same, and make sure to register collision between the types. Order does not matter. The collision conditions (with the exception of the is touching conditions) needs to be the first condition of the event to function. What condition that should be used depends of what kind of collision you want to register.

    Note that you don't have to use collision types if you use the Generic conditions, but it can be good to give them types to cut down on the number of MMF calls, which can be slow if there's a lot of collisions being reported.

    2. Here's an explanation of the different condition:
    * On Collision Begin - Called when 2 bodies begin touching.
    * On Collision End - Called when 2 bodies stop touching.
    Note that these callbacks give you no other information than that the collision has occured. If you need to know the force of the collision the following conditions are needed.

    * On Contact Point Add - Called when a contact point is created. A single collision can have multiple contact points. In this event you can get extra information such as collision angle, relative friction, velocities etc.
    * On Contact Point Removed - Called when a contact point is removed.
    * On Contact Point Persist - Called continuously as long as a contact point exists. Extra information is available here as well.
    * On Contact Point Response - Called when a contact is resolved. This is where you can get info about what impulses the contact has generated, the info differs slightly from the other contact point events.

    * On Contact Evaluation - This is called right before any collision occurs. Use this callback to evaluate on the fly if 2 bodies should collide or not. Use the action Collisions -> On Collision Evaluation -> Sensor current Collision during the callback to make the bodies not collide.

    * Body is Touching another Body - Used to check if 2 bodies are currently touching. This is not a callback and is used the same way as MMF's Object is Overlapping another Object.
    * Shape is touching another Shape - Same as above but for shapes.
    * Body is Touching Type - Used to test if a Body is touching a body of a certain type.
    * Shape is Touching Type - Same as above but for shapes.

    3. There are currently no plans to make a flash port of Box2D as the current Flash version of the Box2D library differs way too much from the highly customized version used in the extension.

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: A few Box2D questions...

    Thanks for the info... I'm starting to wonder if something is broken... because I can't seem to get any of the collision events to work now. I put even the most basic event and do a test and get nothing back from it, even though contact is definitely happening between various shapes.

    I tried "body is touching another body" and got no response...

    I tried "On Contact Point Add - Generic" and got no response... even though the amount of contacts goes up when an object touches another one... Nothing in these events seems to be working.

    Here's what I added:

    Set Collision Type of Shape (-1) of Body (Hero Object) to (1)
    Set Collision Type of Shape (-1) of Body (Block Object) to (2)

    Register Collision for Types (1) and (2)

    + On Contact Point Add Between Types (1) and (2)
    - Add 1 to Global Value O

    I run this, push the hero object against some block objects... I get nothing in the global values list at all... What's going on? Am I missing something?

  4. #4
    Forum Moderator

    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,773
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)

    Re: A few Box2D questions...

    Hi Konidias. I have an open source example using box2D on my website at:
    http://www.castles-of-britain.com/mmf2examplespage18.htm

    Maybe that will help.

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

  5. #5
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: A few Box2D questions...

    That code should work, are you sure you're setting the collision type after the shapes have been created and not before? I've made that error myself...

  6. #6
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: A few Box2D questions...

    I figured out what the problem was. =) At some point I was removing the shape of the hero object and adding a new shape but I wasn't re-adding a collision type for that shape. Thanks for all the help guys!

Similar Threads

  1. [RC] Box2D
    By Looki in forum Beta Flash Extensions
    Replies: 32
    Last Post: 25th March 2013, 06:16 PM
  2. How to do this? :D Box2D?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 19th September 2012, 08:52 AM
  3. Box2D help
    By Pixzel in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 30th June 2012, 05:38 AM
  4. Box2d
    By ChrisBurrows in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 22nd March 2012, 12:54 AM
  5. Two quick unrelated questions (Box2D and Surface)
    By Jacob in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 7th October 2010, 10:01 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
  •