Collision with curved vertex

Hello everyone,
I am trying to make a simple game where one object is moving between to curvedVertexes.
Now I want to add an event incase the object is colliding with the obstacles aka the curvedVertexes. I have found “collidePointPoly()” (https://github.com/bmoren/p5.collide2D#collidepointpoly) to be a simular case. But once I have tried it out, the function stayed false even if there was a collision.

https://glitch.com/edit/#!/wave-collision?path=index.html:181:1 (this is the link to my glitch project, since I find this the easiest to share)


lowerhit should turn true, once the ball enters the tourquise area.

Does anyone know why this is not working?
Thank you very much for the support

1 Like

Not sure why the collision code isn’t working :confused:

I do however have an alternative. It’s not p5.js, but I’m sure it should be easy to implement.

The only problem is the collision isn’t accurate. I made an example where it’s clear what the difference between the graphic and the collision would be :
example5

The only way I can think of to fix this is somehow extracting the vertex data from the curveVertex and using that to define the polygon

1 Like

Thank you for your response.
I don’t mind the incorrectness too much, but I don’t really understand how I am able to transfer this script into javascript.
Could you help me?

This is the project I have created therefore. I am very confused on how to transfer boolean into javascript. Also: Am I supposed to replace every PVector with creatVector?
Thank you in advance

I’m afraid I’m too unfamiliar with p5.js to convert the code :fearful:

But I did manage to find a resource full of conversion tips on github

I hope this solves trying to make the boolean work

1 Like

You might be interested in this recent discussion of finding an intersection on a curve using line-line detection, where each part of the curve is a line segment.

You could use circle-line collision detection in a similar approach.

1 Like