Jump to content

Vehicle Implementation Using 2.31


darrenc182
 Share

Recommended Posts

I am having trouble implementing vehicles using the raycast vehicle implementation with Leadwerks Engine 2.31. Below is how I am creating the vehicle:

 

       pos = EntityPosition(vehicle);

if(!CreateEntity(vehicle))
	return false;

PositionEntity(vehicle, pos);
SetBodyMass(vehicle, 5.0f);
EntityType(m_Entity, 3);

wheel[0]=LoadModel("abstract::hmmwv_tire.gmf");
wheel[1]=LoadModel("abstract::hmmwv_tire.gmf");
wheel[2]=LoadModel("abstract::hmmwv_tire.gmf");
wheel[3]=LoadModel("abstract::hmmwv_tire.gmf");

tire_pos[0] = EntityPosition(FindChild(m_Entity, "Tire01"), 0);
tire_pos[1] = EntityPosition(FindChild(m_Entity, "Tire02"), 0);
tire_pos[2] = EntityPosition(FindChild(m_Entity, "Tire03"), 0);
tire_pos[3] = EntityPosition(FindChild(m_Entity, "Tire04"), 0);

m_vVehicle=CreateVehicle(m_Entity);
int tire1 = AddVehicleTire(m_vVehicle,tire_pos[0], 5.0f, 0.0f, 20.0f);
int tire2 = AddVehicleTire(m_vVehicle,tire_pos[1], 5.0f, 0.0f, 20.0f);
int tire3 = AddVehicleTire(m_vVehicle,tire_pos[2], 5.0f, 0.0f, 20.0f);
int tire4 = AddVehicleTire(m_vVehicle,tire_pos[3], 5.0f, 0.0f, 20.0f);

 

The variable vehicle stores the vehicles chassis mesh. When the vehicle is created it does one of two things. The vehicle's chassis either falls half way through the floor of my level or it bounces all over the place.

 

This image illustrates what I was talking about with the vehicle falling half way through the floor.

post-212-037046400 1278110224_thumb.jpg

 

This second image shows the physics bodies for the vehicle and the vehicle's wheels.

post-212-016516200 1278110236_thumb.jpg

 

This final image shows the start position of the vehicle when it is created. This is the position that is received from the PositionEntity(vehicle, pos) function call.

post-212-038641300 1278110244_thumb.jpg

 

Here is the update code for updating the vehicle every clock cycle.

       TVec16 chassisMatrix;

SetEntityMatrix(wheel[0],GetTireMatrix(m_vVehicle,0));
SetEntityMatrix(wheel[1],GetTireMatrix(m_vVehicle,1));
SetEntityMatrix(wheel[2],GetTireMatrix(m_vVehicle,2));
SetEntityMatrix(wheel[3],GetTireMatrix(m_vVehicle,3));

       SetSteerAngle(m_vVehicle, 25.0f, 0);
SetSteerAngle(m_vVehicle, 25.0f, 1);

 

I would really appreciate any and all help with this problem because it's been kicking my butt for a long time. I don't know if it's a problem with my implementation or if it is a limitation of the vehicle implementation within the engine. Like I said any and all help to correct this problem will be greatly appreciated. Thank you in advance.

Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...