- Home /
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.
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.
Answer by GuyTidhar · Sep 11, 2011 at 12:41 PM
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.
Your answer
Follow this Question
Related Questions
How do I check if/where in a sprite another sprite is? 0 Answers
(2D intersection+picture)How to show up the invisible object when intersect with another object. 1 Answer
Collision problem 0 Answers
I'd like some help with my health / shooting (collision detection) 1 Answer
Weapon System with collide detection (Helps with script pls)!!! 0 Answers