Hi all,
Not sure where to post support requests, doesn't seem to be a section for it. Not sure if people use this forum, either... but I'll try.
My question: does this library support kinematic collisions with static objects? I've just tried to implement something very simple and I can't get it to work at all - the entity falls right through the segment without colliding.
I create a space. I make a platform segment using the static body of the space. I set it to start at -20, 1 and end at 20, 1. I've tried changing the value of the radius to other values as well. And after that, I add the shape to the space.
Code: Select all
cpSpace* space = cpSpaceNew();
cpShape* platform = cpSegmentShapeNew(cpSpaceGetStaticBody(space), cpv(-20, 1), cpv(20, 1), 0);
cpSpaceAddShape(space, platform);
I used cpSpaceAddbody to create a kinematic body for the entity. I set its position above the platform. I create a box shape for it and add it to the space. Not sure what the radius does here for polygonal shapes.
Code: Select all
entity->rigidbody = cpSpaceAddBody(space, cpBodyNewKinematic());
cpBodySetPosition(entity->rigidbody, cpv(4.5f, 5.5f));
entity->shape = cpSpaceAddShape(space, cpBoxShapeNew(entity->rigidbody, 1.2f, 0.8f, 0));
Code: Select all
float speed = 50.0f;
accel = accel * speed;
accel = accel + entity.velocity * -8.0f;
accel.y = -30.0f;
entity.velocity = (accel * deltaTime) + entity.velocity;
cpBodySetVelocity(entity.rigidbody, cpv(entity.velocity.x, entity.velocity.y));
Code: Select all
cpSpaceStep(state->space, input->deltaTime);
Thanks in advance for your help.