x


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

more ▼

asked Sep 11 '11 at 11:02 AM

Jordii gravatar image

Jordii
158 9 11 17

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

Aug 06 '12 at 10:32 AM joon
(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Why not just use colliders?

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

more ▼

answered Sep 11 '11 at 12:41 PM

GuyTidhar gravatar image

GuyTidhar
2.2k 4 8 13

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.

Sep 11 '11 at 01:13 PM Jordii
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2482
x1032
x38

asked: Sep 11 '11 at 11:02 AM

Seen: 1185 times

Last Updated: Aug 06 '12 at 10:32 AM