A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Issues with collision detection

  1. #1
    Junior Member
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    4

    Issues with collision detection

    Hi all,

    first of all: sorry for my english, but I am not an english native

    I am working now with 3DFA for almost 2 weeks. I watched the great tutorials from blanius and learned a lot. But I stuck with the collision detection.

    In his example, blanius uses a square and a circle (standard objects of 3DFA). But what if you have to use non-standard objects. For example an object formed like an aircraft. In my case I used an object shaped like an UFO. Therefor I "painted" the UFO with the bezir curve funktion of 3DFA. So far so good

    But the collison detections is not working correctly with this. The collision is detected to early. So the UFO explodes before the other object optically hits the UFO.

    I hope you understand what I am trying so hard to explan
    Has somebody a solution for my problem?
    Thanks in advance.
    Greetings
    zeiger

  2. #2
    Junior Member
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    4
    Hi again,

    to explain my problem in more detail, I have followed the online tutorial from blanius step by step and created a swf-file. And to my surprise even there the problem shows up.

    Flash example

    The collision detection has been implemented with the collideRect method.

    Does somebody has an other idea how to implement a collision detection?

    Help is always appreciated

    Greetings
    zeiger
    Last edited by zeiger; 11-14-2006 at 04:39 PM.

  3. #3
    Senior Member
    Join Date
    May 2005
    Posts
    163
    CollideRect takes the rectangular coordinates of the item you have drawn. So what you have to imagine is the smallest rectangle the item you drew fits in and it's that rectangle that's used for the collision detection not the item itself.

    I currently can only suggest 2 ways to do collision on non-rectangular items. The 1st is to do the collision detection yourself using a script and the x/y coordinates of the items (not very easy to do). The 2nd is to put invisible objects (like dots) around the perimeter of your items and do the collision detection using collideRect on these (can make a lot of objects but I think is much easier to do).

    Maybe someone else has other ideas. Anyway hope this gives you someplace to start.

  4. #4
    Junior Member
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    4
    Quote Originally Posted by ppedz
    CollideRect takes the rectangular coordinates of the item you have drawn.
    OK. That point I was missing. Now the CollideRect function makes sense. Thanks

    BTW: I found this post collision detection with circles

    So if nobody comes with an other solution I have to use only circles/rectangles or I go with your second solution

    Greetings
    Dominik

  5. #5
    Senior Member
    Join Date
    May 2005
    Posts
    163
    The post you found would fall under the 1st suggestion but it only applies to circles. You could do this same type of idea for just about any shape based on it's x/y coordinates. By this I mean make your own type of collision function.


  6. #6
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    The circle collision works for non circles as well, it's based on distance. Where you get complicated is with complex shapes. I recall reading another way to do this, I think it used getBounds

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Does current version of 3dfa have "hitTest"? that would do it.

  8. #8
    Junior Member
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    4
    Quote Originally Posted by blanius
    Does current version of 3dfa have "hitTest"? that would do it.
    I am not 100% sure, but I don't think so.

    So I have to make the best of my situation. Otherwise it would be to easy

    Thanks again for all your help.
    Greetings
    zeiger

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