[SOLVED] Multiple worlds and a character controller?

Post Reply
paulgriffiths
Posts: 13
Joined: Sun Dec 25, 2016 11:31 am

[SOLVED] Multiple worlds and a character controller?

Post by paulgriffiths »

I have multiple worlds and wish to use a character controller http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=5684. I want the feature of the character controller changing worlds.

I setup each world with following code:

Code: Select all

	// Initialize Bullet. This strictly follows http://bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World, 

	// Build the broadphase
	btBroadphaseInterface* broadphase = new btDbvtBroadphase();

	// Set up the collision configuration and dispatcher
	btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
	btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);

	// The actual physics solver
	btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;

	// The world.
	dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
	dynamicsWorld->setGravity(btVector3(0,-9.81f,0));
	dynamicsWorld->setDebugDrawer(&mydebugdrawer);
The problem is the character controller requires a btBroadphaseInterface.
If all the worlds share a single instance of a btBroadphaseInterface the app crashes.

Do I have to include a character controller for each world and direct the movement to my "current" character controller or can I share a single instance of a btBroadphaseInterface and more?

Thank you.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Multiple worlds and a character controller?

Post by drleviathan »

Yes, each world requires its own broadphase instance.

Yes, each world would need its own character instance, although I suppose you could have one instance and just remove from WorldA and add to WorldB as necessary, but have it only be in one world at a time.
Post Reply