need help destroying current vehicle and creating new one.

DjSt3rios
Posts: 7
Joined: Mon Feb 13, 2012 2:45 pm

need help destroying current vehicle and creating new one.

Post by DjSt3rios »

Hello. I am a new game developer, I started developing a few months ago, and I decided to try and make a racing game. I am using bullet for my vehicle physics, but I have a small problem. I want to make a button which will allow you to select a new vehicle, but I want the current vehicle to be destroyed. I am using RaycastVehicle, and I have bullet physics engine integrated with another engine. So far I tried this:

Code: Select all

Model *player = GetTargetNode();

	BulletScene *rootScene = static_cast<BulletScene *>(TheBulletExtrasPlugin->GetRootScene(GetTargetNode()->GetWorld()->GetRootNode()));
	btDiscreteDynamicsWorld *dynamicsWorld = rootScene->GetDiscreteDynamicsWorld();

	if(player->FindNode("Chassis"))
	{
		body->setActivationState(WANTS_DEACTIVATION);
		dynamicsWorld->removeRigidBody(body);
		dynamicsWorld->removeVehicle(vehicle);
	}
Some of the functions might be from C4 though, but I hope you might get an idea what I have done so far. With this code, when I run it the car stops moving, I cant move at all, although the game does not crash, it doesn't do anything, but my model(car) is still there... what else can I try to do?
jauthu
Posts: 12
Joined: Tue Feb 28, 2012 7:34 pm

Re: need help destroying current vehicle and creating new on

Post by jauthu »

I don't see any of code corresponding to removal of model itself. So, it is not the Bullet question, I think.
DjSt3rios
Posts: 7
Joined: Mon Feb 13, 2012 2:45 pm

Re: need help destroying current vehicle and creating new on

Post by DjSt3rios »

I fixed it, thanks anyway