User Tag List

Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 34

Thread: Physics

  1. #1
    No Products Registered

    Join Date
    Oct 2011
    Location
    Canada
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Physics

    I've been playing around with box2d it's pretty cool. As far as I've gotten is making things tumble though. I'm having a bit of hard time figuring out how to make an active object (sprite) interact with the boxes though. How would this be done? There doesn't seem to be a whole lot of tutorials or docs on the extension.

    Are there other engines, and alternative as well?

  2. #2
    Clicker Multimedia Fusion 2 Developer
    gastrop0d's Avatar
    Join Date
    Dec 2011
    Location
    Australia
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I know, if you want something to interact in the physics simulation, it must be part of the simulation. This entails adding those objects into the physics world.

    So, if you have a player sprite, you have to make a box (or whatever shape, maybe a circle) physics body & shape to correspond to that player. Then you'll have to fiddle with the forces at play on that object, as well as enable/disable collision types to get the kind of behaviour you want for the player object.

    You can still do collision tests as normal for non-physical reactions. For example, a player colliding with a powerup object and the powerup disappearing will work just fine. But anything physics based like telling the player to stop or bounce will not work properly, if at all.

    Actually the more I think about it, there are still some basic things you can do. If you gave your player a custom platform movement for example instead of adding him to the physics simulation, you could probably still do stuff like:

    Player collides with crate:
    - Apply force to crate //where force is the reactive force to the collision. Ie subtract the position of the crate from the position of the player to get the direction and use the speed of the player multiplied by the mass of the crate as the magnitude of the force. This should send the crate tumbling or sliding away from the player when they bump into it
    - Set Player speed to 0 //player stops when they bump into it

    However, if the crate collides with the player, in the case where the crate is just flying through the level for some reason and rams into him, this will probably be completely screwy and the crates behaviour will be completely wrong. You might... might be able to cajoule it into working properly with exactly the right force application, but I'm pretty bad at physics so I don't know exactly what the formula would look like.

    Short story: you probably can jury rig physics interaction between objects in and out of Box2D's simulation, but I predict it would be a headache, so recommend keeping all your physics inside Box2D.

  3. #3
    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)
    Jibs. There is an open source example on my website.

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

  4. #4
    No Products Registered

    Join Date
    Oct 2011
    Location
    Canada
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sweet, thanks for the lengthy bit of of info. I realized that I needed things to be within the physics world of box2d for all things to interact with each other. This is where it started getting confusing, because I was having a hard time figuring out how to do what you had mentioned.

    "you have to make a box (or whatever shape, maybe a circle) physics body & shape to correspond to that player. "

    on another topic I've had a hard time with collision boxes, I'm not certain how they work. I've seen mfa files where the sprite takes the place of the box and what not, but I haven't fully figured that out yet. Can you set a box to box2d and give it user controls?

    Marv, is there any chance you can tell me what page, or even file name to look up?

    I guess I'm looking for physics to make things like throw-able objects...like the tossing of a grenade. I found a good boomerang tut, lol. I'm more interested in being able to have the object not come back, but fall some distance from the player.

    I may not even need box 2d for this I'm not sure.

    I'm trying to slowly introduce myself to physics so I can achieve these sorts of things.

    Thanks again,
    Jb.

  5. #5
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Stephen's Avatar
    Join Date
    Aug 2008
    Location
    Montana
    Posts
    4,515
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    _____________________________________________
    Nivram's Examples -Need extensions? Send me a PM.-


  6. #6
    No Products Registered

    Join Date
    Oct 2011
    Location
    Canada
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh my Marv I definitely love you haha. Your lob example shall prove very useful

  7. #7
    Clicker Multimedia Fusion 2 Developer
    gastrop0d's Avatar
    Join Date
    Dec 2011
    Location
    Australia
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jibs View Post
    on another topic I've had a hard time with collision boxes, I'm not certain how they work. I've seen mfa files where the sprite takes the place of the box and what not, but I haven't fully figured that out yet. Can you set a box to box2d and give it user controls?
    Essentially you have a box, defined from a hotspot, typically at the centre. The offset values are where the hotspot is in relation to the x/y of the sprite, and the width/height values define the bounds.

    So if you have the hotspot of your player sprite in the absolute centre of the player sprite, then your offset for creating the physics body will be 0,0. You bounds will always be X Right("player") - X Left("player), Y Bottom("player") - Y Top("player").

    If your hotspot ISN'T in the centre of your sprite, that's where things seem to get uber confusing. I had a really, really hard time myself trying to get the body definitions lining up with active objects whose hotspots weren't completely centred. Call it a failure of comprehension, perhaps?

    Something like lobbing a grenade shouldn't be too hard.

    Create the grenade at the player position, give it a force that is angled upwards in the direction the player is facing. Should lob nicely.

  8. #8
    No Products Registered

    Join Date
    Oct 2011
    Location
    Canada
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "Something like lobbing a grenade shouldn't be too hard."

    Yup. I actually played with that a bit, and was messing around with it to get it to bounce a bit before coming to a stop on the ground. Mostly a matter of playing with pinball movement, and the settings. Turned out quite nice.

    when you say "Essentially you have a box" this is essentially a box made out of an active object? one thing I've noticed with box 2d is when you create the body and shape it doesn't seem to react the same way as an active outside box2d..

    umm..you have to use static movement with box2d?

  9. #9
    No Products Registered

    Join Date
    Oct 2011
    Location
    Canada
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey where do I set up these bounds for the collision box?

    "You bounds will always be X Right("player") - X Left("player), Y Bottom("player") - Y Top("player")."

    Is that through box2d or some other means? When I create body, and shape for my collision box I don't see anything asking for bounds...just offset angel, and stuff like that.

    Thanks again for the help guys, I appreciate it, and learning all this

  10. #10
    No Products Registered

    Join Date
    Oct 2011
    Location
    Canada
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Learning Collision physics.mfa

    I've added the mfa I'm working with. Very simple, just trying to get the box to add to player controls. I've set up the body and shape for collision platform, and collision box. I can't seem to figure out how to get the collision box to follow player controls though.

    I've tried adding it to pmo at start of frame on the same condition sprite is added, and separate condition, but neither worked, lol.

Page 1 of 4 1 2 3 ... LastLast

Similar Threads

  1. Physics question! Making AI that uses Physics Platformer/Physics Static movement
    By Krim in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 13th December 2013, 03:19 AM
  2. Using physics objects with non physics movements
    By Redsquirrel in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 11th December 2013, 01:51 PM
  3. Possible to make some simple object fall physics without physics engine?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd March 2012, 08:56 AM
  4. top down physics with the physics extension?
    By cel in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 24th April 2009, 08:04 AM
  5. Physics Bug
    By eceva in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 16th February 2008, 01:45 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
  •