;

PDA

Click to See Complete Forum and Search --> : Issues with collision detection


zeiger
11-13-2006, 03:27 PM
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 :rolleyes:
Has somebody a solution for my problem?
Thanks in advance.
Greetings
zeiger

zeiger
11-14-2006, 03:37 PM
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 (http://www.freegames24.de/spiele-entwicklung/collision/)

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

ppedz
11-14-2006, 04:27 PM
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.

zeiger
11-14-2006, 04:57 PM
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 (http://board.flashkit.com/board/showthread.php?t=464360)

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

Greetings
Dominik

ppedz
11-14-2006, 11:38 PM
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.

:)

blanius
11-14-2006, 11:52 PM
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

blanius
11-14-2006, 11:56 PM
Does current version of 3dfa have "hitTest"? that would do it.

zeiger
11-15-2006, 03:46 PM
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 :D

Thanks again for all your help.
Greetings
zeiger