You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CoffeePhysics isn't a rigid body engine, so it doesn't currently handle polygon collisions in that way.
One option you have is to make your square from 4 particles, connected by very stiff springs. Connect them around the perimeter of the square and in a cross. Something like:
var squareSise = 50;
// Corners
var tl = new Particle();
var tr = new Particle();
var br = new Particle();
var bl = new Particle();
// Perimeter
var s1 = new Spring(tl, tr, 50, 1.0);
var s2 = new Spring(tr, br, 50, 1.0);
var s3 = new Spring(br, bl, 50, 1.0);
var s4 = new Spring(bl, tl, 50, 1.0);
// Cross
var s5 = new Spring(tl, br, 50, 1.0);
var s6 = new Spring(bl, tr, 50, 1.0);
This will bounce off walls, thought there might be some slight elasticity as the springs compress. Also, collisions between squares won't be handled if 2 rotated squares intersect.
If you need this kind of behaviour, I suggest you use a rigid body engine like Box2d :)
I tried doing that but the collision detection isn't working. I'm trying to have the ball stop at the platform. If you could give this a look, I'd really appreciate it.
Hello, I'm trying to have a platform with a rectangle shape, and I'm not seeing how I can add that shape.
I can have the drawn part and a Particle interacting well, but the Particle has the shape of a circle. Is there a way to have a rectangle shape?
The text was updated successfully, but these errors were encountered: