# Polymap collision test devlog topic

### welcome to the pmctdt

this will just serve as a devlog for my polymap collision test I’ve been working on for a bit now

may or may not turn it into a full game

Tag Lists
• Mention me for all minor devlogs (includes gif)
• Mention me for all major devlogs (includes video or is long)
• Mention me for all public releases
0 voters

previous messages
related media

videos

polygon map multi-object collision demonstration — YouTube

public releases
8 Likes
4 Likes

This is looking insane! Do you mind explaining how it works?

4 Likes

This is super cool

Do you think you will be able to make it lag free?

2 Likes

In order:

1. Each object sends their position, velocity, and size to a variable called the Collision Request Queue, or ColReqQueue
2. All the lines (invisible objects) that aren’t the start of a new shape [1] each go through all the collision requests at roughly the same time
3. The difference of the line’s vertices (d) and the normal of the line (n) are calculated
• d=v_{ert1}-v_{ert1}
• n=(-d_y,d_x)\div\sqrt{d_x^2+d_y^2}
4. The object’s X and Y positions are projected onto the line
• x_{proj}=v_{ert1}+(v_{ert2}-v_{ert1})*\frac{o_{bjX}-v_{ert1X}}{d_x}
• y_{proj}=v_{ert2}+(v_{ert2}-v_{ert1})*\frac{o_{bjY}-v_{ert1Y}}{d_y}
5. Figure out where the object’s travel path (assuming it never changes velocity) and the line intersect (l)
6. Check if the intersection really happens and if we even need to care
7. Give the object the intersection point
8. Once the object receives it via message it’s position is set to it and it’s velocity is set to 0
9. After every line is done calculating the queue is cleared and the process repeats

stuff here may be simplified

I guess this counts as a major devlog?

1. (in the data, this is denoted with a +) ↩︎

2. NOTE: certain values are subtracted by 0.0001 to prevent divide by 0 errors ↩︎

3 Likes

I could make an extra very minor optimization but beyond that probably not

thanks!

2 Likes

Cool

it’s really interesting to see this in action

1 Like

aghhh gotta figure out how to detect corner edge collisions of either or

I got it for the object’s corner hitting a line’s edge but idk how I’d do it for the corner of two lines hitting the edge of the object

there’s also weird invisible ceilings at places so not sure what’s up with that

3 Likes