I've just started using Bullet Physics lib and have been browsing through the posts in this forum for a solution to a problem I came across, but didn't find anything.
My use case is that I want to have "active areas" in my game that trigger actions - like powerups, ammo givers etc. I want an actor to be able to walk over them so that the collision is detected, but I don't want the actor to bump against them.
I represent an actor using a btRigidBody with a mass, and I thought that using btGhostObject to represent the active areas would be a good idea, but for some reason when the actor comes across the area, it bumps off it?
Could you tell me what's wrong?
This is the code I have to set up the entities:
Code: Select all
enum ObType
{
OT_STATIC = 1,
OT_DYNAMIC = 2
};
btDiscreteDynamicsWorld* m_collisionWorld = /* some initialization */;
float actorMass = 1;
btRigidBody* actor = new btRigidBody(actorMass , motionState, new btSphereShape(1), btVector3(0, 0, 0));
actor->setCollisionFlags(0);
collisionWorld->addRigidBody(actor, OT_DYNAMIC, OT_STATIC | OT_DYNAMIC);
btGhostObject* powerup = new btGhostObject();
powerup->setCollisionShape(new btSphereShape(1));
powerup->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
collisionWorld->addCollisionObject(powerup, OT_STATIC, OT_DYNAMIC);
... and I run the simulation like so:
Code: Select all
collisionWorld->stepSimulation(timeElapsed, 4);
Cheers,
Paksas