Custom Convex And Concave Colliders

Colliders in hopscotch are good, but where they have functionality, they lack compatibility with @Spy_Guy_96’s physics engine. To solve this problem I thought of a method using strings to create colliders. Step one in the process is creating a list of points that represent the colliders vertices, an example of this would be for a square we would have [1,1],[-1,1],[-1,-1],[1,-1], we will define this list as local variable collider point array, note that these points are listed in rotational order because that will be important later, now to find if a point is within the collider you would need to find the angle the point makes with the collider, arctan((x1-x2)/(y1-y2)) which we will define as variable angle. Now, to find if a point intersects a collider you also need to find the distance of the colliders ((x1-x2)^2 + (y1-y2)^2)^(1/2), we can define this local variable as distance. Finally we have to get the closest two indexes in the string to the variable angle and we will divide it by the amount of points in the collider point array and round it to the nearest whole number, then we will find the next closest point which is the next or the previous item in the array, after this we need to find where the ray formed by the angle intersects with a segment between these two points, then we find out whether the distance of the point of intersection is closer or further then the variable distance by using ((x1-x2)^2 + (y1-y2)^2)^(1/2), if the point is closer than the intersecting point then the the point is inside the collider. @Spy_Guy_96, if you have a chance or idea of a way to implement this into a collision system it could help create a better physics engine for hopscotch. Provided the strings don’t lag the game as much. @CreationsOfaNoob, if Spy_guy_96 manages to implement this into a physics engine you might be able to implement friction and rolling the same way you did in your ball physics project.

An alternative to this method would be to use a list of distances of the vertices of a collider instead of a normal list so you could skip the process of finding out the intersection of the ray formed by the angle and the line segment formed by the two points.


You lost me here, I have no idea what you mean.
sorry lol


i might be wrong but it’s arctan[(y2-y1)/(x2-x1)


Maybe, I am sleep deprived…


It’s to find the angles between the two objects that we are checking if they collide @Spy_Guy_96

1 Like

Is this basically an easier way to make collision with shapes and shapes with holes in them? I understand the title but i don’t understand what you wrote.


It is a concept, I haven’t tested it but it may be faster then normal image colliders. It may also be possible for it to be used with spy_guy_96’s physics engine.