+ 2

Polygon Collision

Does anyone know how to handle triangle -> circle collisions? I read on Stackoverflow it is a similar method to circle -> circle, but here it won't work. https://code.sololearn.com/WKipUEZULwLG/?ref=app

10th Jun 2019, 3:06 PM
Clueless Coder
Clueless Coder - avatar
7 Antworten
+ 4
You could use a npm module. https://www.npmjs.com/package/triangle-circle-collision Then use browserify to bundle it into a js file.
10th Jun 2019, 4:05 PM
Calviղ
Calviղ - avatar
+ 4
Hi Farry , I've decided to try again at games. I've messed up already. Every 1 second it is meant to spawn an ellipse at a random location. All it does is teleport. How can I make it spawn in a random place, and stay there. I would use variables, although they only work once. Can you help? edit: I am working on it now, I think I have an idea. I will get back to if it doesn't work edit: Just as I thought, not working https://code.sololearn.com/WeLuUVw4NvuS/?ref=app
11th Jun 2019, 2:58 PM
Clueless Coder
Clueless Coder - avatar
+ 2
Farry Good, although I meant like this code https://code.sololearn.com/WV0K3dX75RYb/?ref=app Where it spawns 1 sprite/ball at a random location and stays there
11th Jun 2019, 5:16 PM
Clueless Coder
Clueless Coder - avatar
+ 1
convex polygon collisions can be handled using SAT (separating axis theorem) which briefly states that as long as you are able to draw a line between the objects, they aren't colliding. i haven't implemented it before so i don't think i would be able to help in its implementation. there's an other way for dealing with polygon collisions which i often to. the trick is to treat every polygon as a circle and use the simple Pythagorean theorem to determine if the (pseudo) circles are colliding. it is not the best but often does the job. at least when you don't want to use SAT.
10th Jun 2019, 3:19 PM
Farry
Farry - avatar
+ 1
Calviղ or even simpler, a physics engine?
10th Jun 2019, 4:08 PM
Farry
Farry - avatar
11th Jun 2019, 5:12 PM
Farry
Farry - avatar
0
Calviղ Farry Just tried it, didn't work 😂 https://code.sololearn.com/WgEhP6AzzLBw/?ref=app This is so hard! 😅
20th Jul 2019, 12:55 PM
Clueless Coder
Clueless Coder - avatar