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.
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 :
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
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
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.