Overlap detection

Hey everybody. I am currently working on a bomberman-like game, and porting the engine I already wrote in Actionscript to Unity3D. Now every square in my game is 1x1 unit.

Now my problem is this. I need to detect whether my player (blue donut ;)) is on top of a bomb. I check each corner in 3D space, translate to a position in my 2D field array, and check whether that square is a bomb or not.

In Actionscript I used to get my top-left X and Y. And for some corners add the width/height of the player, MINUS one pixel, to be sure I have the inner bounds. So in Flash, for my character I’d grab his top-left X and Y, and do something like topRightCoord = character.rect.x + character.rect.width - 1.

alt text

However, in Unity this proves to be more of a challenge. How do you know the inner bounds of your character? If I would simply do character.rect.width + 1 it would be on the OUTSIDE of my character.

I hope this explains my problem. What is the most common way to check these kind of things?

Thanks so much,

Jordi

I am interested in this as well, would be useful for checking if GUI textures overlap.

1 Answer

1

Why not just use colliders?

For instance: http://unity3d.com/support/documentation/Components/class-BoxCollider.html

Well I've been able to build my entire system without the use of collision detection from Unity seeing Bomberman like movement is rather basic. It's a possibility, but it seems like bit of overhead for such a task.