A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] two rectangle collision REACTION

  1. #1
    Collision Noob
    Join Date
    Dec 2009
    Location
    Some unhappy flat
    Posts
    11

    resolved [RESOLVED] two rectangle collision REACTION

    lIs there any AS 3.0 (or anything) tutorial on colliding non-circular shapes? I'm desperate, cause I cannot figure this one out. Nor google it. Nor find it via flash'kit search. I do not know how to make a correct inquery. It just throws circle collisons, or nonmoving rect+circ collisions, or car wall collisions. But I need a collision REACTION.

    Say we have 2 rectangles. rect.A runs into rect.B back from side. How much should we rotate them? We know velocities, frictions, exact collision point, everything before the collision. But what to do next?

    I'm probably not the first desperate trying to figure it out. But It's killing me! Whole week. I've been reinventing the bike for some 8 days now. Help? Anyone? Please?

  2. #2
    Collision Noob
    Join Date
    Dec 2009
    Location
    Some unhappy flat
    Posts
    11
    Looks like the brainy people were sent to mars.

    I've encapsulated my game objects (space ships) in circle shaped energy field and do collision testing from there. Not so suitable workaround, but no other options around.

  3. #3
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    Yeah, I don't know why nobody answered you...

    What you're talking about is called "rigid body dynamics". It's a branch of physics that describes the way rigid objects move (and collide) in space. It's the main feature of most game-related physics engines.

    Chances are, you don't want to deal with all the math yourself - it's a pain. Fortunately for you, there are lots of fancy AS3 physics engines you can use for free. Google around a bit to find one you like. Then follow a tutorial to add it to your game.

    http://www.google.com/search?q=as3%20physics%20engine

    Good luck!

  4. #4
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    I have made a very small and very buggy physics engine before, here is the .fla
    Attached Files Attached Files
    Syntax Error

  5. #5
    Collision Noob
    Join Date
    Dec 2009
    Location
    Some unhappy flat
    Posts
    11
    Rigid body dynamics. Thanks's Nialsh. I just neeeded someone to shove me into right direction. Although I think I want to deal with that pain myself . I think it will be somehow less, than incorporating alien classes into my code. I will get lost sooner than in those math formulas.

    Adamkyler - your creation is interesting indeed. I tried something similar when dealing with my problem. I imagined my rectangle as two balls springing to eachother at certain offset.


    Forgot to mention, I have a little question, not worthy of starting a thread.

    Say we have a movieClip, containing another 20 movieClips, while their .visible property is set to false - will they consume less memory,than when being visible? Cause in both cases they ARE PRESENT.
    Last edited by DespeRat; 12-07-2009 at 09:16 PM.

  6. #6
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    I think they use the same memory.
    Syntax Error

  7. #7
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    I've never seen a Flash program that allocated too much memory. Making things invisible can make improve speed because it reduces the rendering time. But I wouldn't worry about it - just write your code the easy way and if it ends up being a problem, you can always optimize later.

  8. #8
    Collision Noob
    Join Date
    Dec 2009
    Location
    Some unhappy flat
    Posts
    11
    Ok. Noted

    And this thread should be marked as solved. Googling "rigid body reactions" does the trick. There are lots of formulae concerning distribution of mass, but nothing impossible.

    I hope to cover this stupid mistake of mine with a greatness of my slowly upcoming flash game. Take care everyone.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center