Sliding Car
Posted: Mon Aug 03, 2009 6:51 am
G'Day gang,
In a little game we're writing, the primary purpose is to have a Kart racing game. We have taken the dimensions from http://www.kartbuilding.net/racingkart/ ... sembly.pdf and have gone through trying to use the DEMO's as a walkthrough.
One little question before I move onto the big one. Does the compoundbody used in the demo help with putting extra weight to the back of the vechicle to stabalise it??
Now the big question, what can I do to make the kart behave more stable? (so it doesn't slide so much at every corner and have a heart attack when it hits a bump and stuff)
These are the properties I've used for the wheels:
private const float FORWARD_SPEED = 30f;
private const float BACKWARD_SPEED = 10f;
#region privateWheelVariables
private float _suspensionLen = 0.4f;
private float _suspensionConstant = 42f;
private float _slidingFricition = 0.6f;
private float _rollFriction = 0.02f;
private float _grip = 0.6f;
private float _maxSuspensionForce = 600f;
private float _suspensionDamp = 0.8f;
#endregion
and for the body of the car:
const float bodyWidth = 0.815f;
const float bodyHeight = 0.33f;
const float bodyLength = 1.59f;
const float bodyMass = 160f;
const float wheelRadius = 0.135f;
const float wheelLength = 0.2f;
and I attach the wheels like so:
//Using Convex Cast Wheels
#region Wheels
Quaternion initialWheelRotation = Quaternion.CreateFromAxisAngle(Vector3.Forward, (float)Math.PI / 2);
Entity wheelShape = new Cylinder(new Vector3(0, 0, 0), wheelLength, wheelRadius);
wheelShape.collisionMargin = 0f;
Wheel wheel;
//Front left wheel
wheel = new ConvexCastWheel(new Vector3(-0.55f, -0.141f, 0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
//Front right wheel
wheel = new ConvexCastWheel(new Vector3(0.55f, -0.141f, 0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
//Back left wheel
wheel = new ConvexCastWheel(new Vector3(-0.55f, -0.141f, -0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
//back right wheel
wheel = new ConvexCastWheel(new Vector3(0.55f, -0.141f, -0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
I'm aware my 'display' objects attach themselves to the game's components list in global variables when they're constructed, so don't have too much of a heart attack when you see the weird 'new's being used Ok, third question, If I seperate my terrain into seperate models, and I have one section I load in as 'ice', can I just set the StaticTriangleGroup's friction property to 0f or -0.3f or something to achieve this? or is there a better way?
Thanks so much in advance,
Scotty
In a little game we're writing, the primary purpose is to have a Kart racing game. We have taken the dimensions from http://www.kartbuilding.net/racingkart/ ... sembly.pdf and have gone through trying to use the DEMO's as a walkthrough.
One little question before I move onto the big one. Does the compoundbody used in the demo help with putting extra weight to the back of the vechicle to stabalise it??
Now the big question, what can I do to make the kart behave more stable? (so it doesn't slide so much at every corner and have a heart attack when it hits a bump and stuff)
These are the properties I've used for the wheels:
private const float FORWARD_SPEED = 30f;
private const float BACKWARD_SPEED = 10f;
#region privateWheelVariables
private float _suspensionLen = 0.4f;
private float _suspensionConstant = 42f;
private float _slidingFricition = 0.6f;
private float _rollFriction = 0.02f;
private float _grip = 0.6f;
private float _maxSuspensionForce = 600f;
private float _suspensionDamp = 0.8f;
#endregion
and for the body of the car:
const float bodyWidth = 0.815f;
const float bodyHeight = 0.33f;
const float bodyLength = 1.59f;
const float bodyMass = 160f;
const float wheelRadius = 0.135f;
const float wheelLength = 0.2f;
and I attach the wheels like so:
//Using Convex Cast Wheels
#region Wheels
Quaternion initialWheelRotation = Quaternion.CreateFromAxisAngle(Vector3.Forward, (float)Math.PI / 2);
Entity wheelShape = new Cylinder(new Vector3(0, 0, 0), wheelLength, wheelRadius);
wheelShape.collisionMargin = 0f;
Wheel wheel;
//Front left wheel
wheel = new ConvexCastWheel(new Vector3(-0.55f, -0.141f, 0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
//Front right wheel
wheel = new ConvexCastWheel(new Vector3(0.55f, -0.141f, 0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
//Back left wheel
wheel = new ConvexCastWheel(new Vector3(-0.55f, -0.141f, -0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
//back right wheel
wheel = new ConvexCastWheel(new Vector3(0.55f, -0.141f, -0.665f), initialWheelRotation, wheelShape,
wheelRadius, Vector3.Down, Vector3.Backward, suspensionLen, suspensionConstant, slidingFriction, rollFriction, grip, maxSuspensionForce, suspensionDamp);
this.vehicle.addWheel(wheel);
new Display.DisplayWheelModel(wheelModel, wheel);
I'm aware my 'display' objects attach themselves to the game's components list in global variables when they're constructed, so don't have too much of a heart attack when you see the weird 'new's being used Ok, third question, If I seperate my terrain into seperate models, and I have one section I load in as 'ice', can I just set the StaticTriangleGroup's friction property to 0f or -0.3f or something to achieve this? or is there a better way?
Thanks so much in advance,
Scotty