# Thread: Object overlap - Overlap area

1. ## Object overlap - Overlap area

Hi all,

I have a doubt. I'm trying to implement a way to calculate the amount of overlapped area in collision between a Active with a obstacle.
For example, I have two actives.
- If the first one is completely covered by the second: Set Counter = 100;
- If the first one is half covered by the second: Set Counter = 50;
- If the first one isn't covered by the second: Set Counter = 0;

And the Counter varies between zero and hundred, depending of overlap area.

Is it possible?

Thanks for all and sorry for my english :/

2. Perhaps you could use distances between hotspots to do this? If it covers the other completely, the hotspots would be at the same position. If the distance is a certain amount, it will cover half.

3. Hi Storsorgen,

Thanks for your help. This method works in some cases, but if I have a active with a irregular form, it don't work :/

4. It's technically possible, but probably not practical.

One way would be to calculate the rectangular "bounding box" overlap, and then run a fastloop to test each individual pixel within that area - which you could do with a 1x1 pixel detector, checking whether it overlaps both objects. That's pretty easy if you just have one of each object type, but as with most things in MMF2, if you have multiple instances it would get a *lot* more tricky (ie. not worth the effort).

http://skydrive.live.com/redir.aspx?...094271BBDA!131

Obviously to make it into a percentage, you just multiply by 100 and divide by the object's area.

5. Hi MuddyMole,

Your example is perfect for me! Thanks a lot Works perfectly here.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•