Class TopDownVehicle

TopDownVehicle

Deprecated

This class will be moved out of the core library in future versions.

Example

// Create a dynamic body for the chassis
var chassisBody = new Body({
mass: 1
});
var boxShape = new Box({ width: 0.5, height: 1 });
chassisBody.addShape(boxShape);
world.addBody(chassisBody);

// Create the vehicle
var vehicle = new TopDownVehicle(chassisBody);

// Add one front wheel and one back wheel - we don't actually need four :)
var frontWheel = vehicle.addWheel({
localPosition: [0, 0.5] // front
});
frontWheel.setSideFriction(4);

// Back wheel
var backWheel = vehicle.addWheel({
localPosition: [0, -0.5] // back
});
backWheel.setSideFriction(3); // Less side friction on back wheel makes it easier to drift
vehicle.addToWorld(world);

// Steer value zero means straight forward. Positive is left and negative right.
frontWheel.steerValue = Math.PI / 16;

// Engine force forward
backWheel.engineForce = 10;
backWheel.setBrakeForce(0);

Hierarchy

  • TopDownVehicle

Constructors

Properties

chassisBody: Body
groundBody: Body
wheels: WheelConstraint[]
world: null | World

Methods

  • Parameters

    Returns void

  • Returns void