Skyline Lua API  Version 1.0
Lua Script Reference for Skyline Game Engine.
vehicle Class Reference

#include <LUA_API_Vehicle.h>

Public Member Functions

void createVehicle (string vehicleName, int sceneEntityID, float posX, float posY, float posZ, float rotW, float rotX, float rotY, float rotZ)
 create a new scripted vehicle to work on. It will need setup with the correct functions. More...
 
void destroy (int vehicleID)
 Destroy and cleanup a vehicle in the scene by the vehicle ID passed through this function You should only destroy id's that are active in the scene. More...
 
int getVehicleID (int sceneEntityID, string vehicleName)
 Get the ID of a vehicle by passing the scene entity ID and a vehicle Name. More...
 
int getActiveVehicleID ()
 
void setAsPlayer (int vehicleID, int isPlayer[1 or 0])
 
int isPlayer (int vehicleID)
 
void setCurrentThrottle (int vehicleID, float throttle)
 
float getCurrentThrottle (int vehicleID)
 
void setCurrentGear (int vehicleID, int gear)
 
int getCurrentGear (int vehicleID)
 
int getRPM (int vehicleID)
 
void setNumOfChassis (int vehicleID, int chassisNum)
 
void setNumberOfWheels (int vehicleID, int numWheels)
 
int getNumOfChassis (int vehicleID)
 
int getNumOfWheels (int vehicleID)
 
void createPhyicsBody (int vehicleID)
 
void addChassis (int vehicleID, int chassisIndex, float posXfloat posY, float posZ, float scaleX, float scaleY, float scaleZ)
 
void addWheel (int vehicleID, int vehicleID, int wheelIndex, int driveWheel, int steerWheel, float posX, float posY, float posZ)
 
void setWheelAsHandbrake (int vehicleID, int wheelIndex)
 
void createWheels (int vehicleID)
 
void setWheelMesh (int vehicleID, string wheelMeshName)
 
string getWheelMesh (int vehicleID)
 
void setWheelRadius (int vehicleID, int wheelIndex, float radius)
 
float getWheelRadius (int vehicleID, int wheelIndex)
 
float3 getWheelGlobalPosition (int vehicleID, int wheelIndex)
 
float3 getWheelLocalPosition (int vehicleID, int wheelIndex)
 
void setMaxSpeed_MPH (int vehicleID, int maxSpeedMPH)
 
void setMaxSpeed_KPH (int vehicleID, int maxSpeedKPH)
 
int getMaxSpeed_MPH (int vehicleID)
 
int getMaxSpeed_KPH (int vehicleID)
 
void setTorqueCurveSlot (int vehicleID, int rpm, int torque)
 
int getSpeed_Mph (int vehicleID)
 
int getSpeed_Kph (int vehicleID)
 
int getVelocity (int vehicleID)
 
void setLinearVelocity (int vehicleID, float x, float y, float z)
 
void setAngularVelocity (int vehicleID, float x, float y, float z)
 
void setLinearMomentum (int vehicleID, float x, float y, float z)
 
void setAngularMomentum (int vehicleID, float x, float y, float z)
 
void setLinearDamping (int vehicleID, float damp)
 
void setAngularDamping (int vehicleID, float damp)
 
void setInverseWheelMass (int vehicleID, int wheelIndex, float amt)
 
void useAirResistance (int vehicleID, int useResistance[0 or 1])
 
void setAirResistance (int vehicleID, float baseValue, float multiplier)
 
void useAntiRoll (int vehicleID, int useAntiRoll[0 or 1])
 
void setAntiRollAmount (int vehicleID, float antiRollAmt)
 
void setMaxSteeringAngle (int vehicleID, float angle)
 
void setSteeringCoefMulti (int vehicleID, float coeff)
 
void setMotorTorque (int vehicleID, int wheelIndex, float torque)
 
void setBrakeTorque (int vehicleID, int wheelIndex, float torque)
 
void setPosition (int vehicleID, float posX, float posY, float posZ)
 
void setOrientation (int vehicleID, float rotW, float rotX, float rotY, float rotZ)
 
void setNumberOfGears (int vehicleID, int numGears)
 
void setGearRatio (int vehicleID, float gearRatio)
 
void setRPM (int vehicleID, int minRpmToGearDown, int maxRpmToGearUp, int minRpm, int maxRpm)
 
void setMass (int vehicleID, float mass)
 
void setDownforce (int vehicleID, float downforce)
 
void setNoWheelsDownforce (int vehicleID, float downforce)
 
void setPairDownforce (int vehicleID, float downforce)
 
void useWheelParticle (int vehicleID, int wheelIndex, int useParticle[0 or 1])
 
void setWheelParticle (int vehicleID, int wheelIndex, string particleName)
 
void setWheelParticlePosition (int vehicleID, int wheelIndex, float x, float y, float z)
 
void setWheelParticleEnabled (int vehicleID, int wheelIndex, int isEnabled[0 or 1])
 
void setCenterOfMass (int vehicleID, float offsetX, float offsetY, float offsetZ)
 
void setLatWheelFrictionStiffness (int vehicleID, int wheelIndex, float stiffnessFactor)
 
void setLongWheelFrictionStiffness (int vehicleID, int wheelIndex, float stiffnessFactor)
 
void setLatWheelFrictionSettings (int vehicleID, int wheelIndex, float asymptoteSlip, float asymptoteValue, float extremumSlip, float extremumValue, float stiffnessFactor)
 
void setLongWheelFrictionSettings (int vehicleID, int wheelIndex, float asymptoteSlip, float asymptoteValue, float extremumSlip, float extremumValue, float stiffnessFactor)
 
void setSuspensionSettings (int vehicleID, int wheelIndex, float damperAmt, float springAmt, float targetValue, float suspensionTravel)
 
void showDebug (int vehicleID, int showDebug[0 or 1])
 
void setCustomDebugMaterial (int vehicleID, string customDebugMaterialName)
 
void useSound (int vehicleID, int soundEnumSection, int useSound[0 or 1])
 
void setSound (int vehicleID, int soundEnumSection, string soundFile)
 
void setVolume (int vehicleID, int soundEnumSection, float volume)
 
void setPitch (int vehicleID, int soundEnumSection, float pitch)
 
void setLength (int vehicleID, int soundEnumSection, float length)
 
void setLooped (int vehicleID, int soundEnumSection, int isLooped[0 or 1])
 
void accelerate (int vehicleID)
 
void decelerate (int vehicleID)
 
void steerLeft (int vehicleID, int overrideSteering, float steeringAngle)
 Calling this command will make the vehicle steer left either by the engine itself or a custom steer angle of your choice. More...
 
void steerRight (int vehicleID, int overrideSteering, float steeringAngle)
 Calling this command will make the vehicle steer left either by the engine itself or a custom steer angle of your choice. More...
 
void handBrake (int vehicleID, float torque)
 
void applyForce (int vehicleID, float axizX, float axizY, float axizZ)
 
void applyForceAtPoint (int vehicleID, float axizX, float axizY, float axizZ, float posX, float posY, float posZ)
 
float getMaxBrakeForce (int vehicleID)
 
int getMoveDirection (int vehicleID)
 
void applyLocalForce (int vehicleID, float axizX, float axizY, float axizZ)
 Apply a local force to the center of the vehicle. More...
 
void applyLocalForceAtPoint (int vehicleID, float axizX, float axizY, float axizZ, float posX, float posY, float posZ)
 Apply a local force at a particular point on the vehicle. More...
 
int getWheel_ContactGround (int vehicleID, int wheelIndex)
 Get if the wheel specified is in contact with the ground and return a 1 or 0 boolean. More...
 
float3 getWheel_ContactPoint (int vehicleID, int wheelIndex)
 Get the point of contact with the floor and bottom of the wheel in world space. More...
 
float getWheel_ContactPosition (int vehicleID, int wheelIndex)
 Return the position of suspensionTravel between 0(not extended) and 1(fully extended). More...
 
float3 getWheel_ContactNormal (int vehicleID, int wheelIndex)
 Return the contact Normal from the specified wheel. This is the normal of the raycasted face. More...
 
float getWheel_ContactForce (int vehicleID, int wheelIndex)
 Return the contact force data from the specified wheel. More...
 
float3 getWheel_LateralDirection (int vehicleID, int wheelIndex)
 get the contact data of the specified wheel and retrieve the LateralDirection More...
 
float getWheel_LateralImpulse (int vehicleID, int wheelIndex)
 get the contact data of the specified wheel and retrieve the LateralImpulse value. More...
 
float getWheel_LateralSlip (int vehicleID, int wheelIndex)
 get the contact data of the specified wheel and retrieve the LateralSlip angle value. More...
 
float3 getWheel_LongitudalDirection (int vehicleID, int wheelIndex)
 get the contact data of the specified wheel and retrieve the LongitudalDirection More...
 
float getWheel_LongitudalImpulse (int vehicleID, int wheelIndex)
 get the contact data of the specified wheel and retrieve the LongitudalImpulse value. More...
 
float getWheel_LongitudalSlip (int vehicleID, int wheelIndex)
 get the contact data of the specified wheel and retrieve the LongitudalSlip angle value. More...
 
void enableAutoMaxSteer (int vehicleID, int state)
 Sets the steering to auto adjust based on speed and reduce the steering angle. More...
 
int getAutoMaxSteerEnabled (int vehicleID)
 Gets whether the steering angle auto reduces based on speed. More...
 
void setSteeringMulti (int vehicleID, float multi)
 Set the multiplier between 1 and 0 to reduce the steering input. Useful for joysticks. More...
 
float getSteeringMulti (int vehicleID)
 Set the multiplier between 1 and 0 to reduce the steering input. Useful for joysticks. More...
 
void followPath (int vehicleID, string pathName, float throttle)
 follow a path simply by calling this function in an update loop.
The movement will automatically be smoothed out based on the setPathAccuracy() accuracy variable. More...
 
int isFollowingPath (int vehicleID)
 return whether the vehicle is currently following a path. More...
 
string getFollowPathName (int vehicleID)
 return the name of the path the vehicle is following More...
 
void setPathAccuracy (int vehicleID, float accuracy)
 Set the accuracy of the path to follow. Lower numbers make the distance to each node before trigger smaller. More...
 
void setPathMaxTurn (int vehicleID, float maxTurn)
 Set the maximum speed of the turning rate for this vehicle. More...
 
void setPathNodeIndex (int vehicleID, int nodeIndex)
 Set the current node index the vehicle should head towards on the currently set path. More...
 
void followPathPosition (int vehicleID, float x, float y, float z)
 Override the default path follow and enter your own point to move to.
In order for this to take effect, you need to pass a "" in the follow path function. See the example below. More...
 
int isDestinationReached (int vehicleID)
 Poll to check if the vehicle has reached its destination. More...
 
vehicle setTagOffset (vehID, wheelID, offset)
 Set TAG offset. More...
 
vehicle getTagOffset (vehID, wheelID)
 Get TAG offset. More...
 

Detailed Description

The following vehicle functions can be used to to control a physX vehicle, either created from an action or from script.
Some commands can be used as setup functions, or others can be used as Control functions in most situations.
Use as vehicle.function()

Here is an example of the vehicle scripting process:

obj = 0;
vehicleID = -1;

wKeyDown = 0;
aKeyDown = 0;
sKeyDown = 0;
dKeyDown = 0;

spaceKeyDown = 0;

bodyMesh = "BKC_NeoCharger";
wheelMesh = "BKC_NeoCharger_Wheels.mesh";

function onInit(objID)
    sky.lprint("LUA: Script Active!"); 
    obj = objID;

-- | Create instantiation of vehicle class.
-- | =======================================

    entID = entity.spawn(bodyMesh, 0,5,0, 1,1,1);
    vehicleID = vehicle.createVehicle("BKC_NeoCharger", entID, 0,5,0 ,0,0,0,0);
    sky.lprint("vehicleID: "..vehicleID);

    vehicle.showDebug(vehicleID, 0);
    vehicle.setMass(vehicleID, 3000);
    vehicle.setCenterOfMass(vehicleID, 0, 0.06, 0.4);

    vehicle.setMaxSteeringAngle(vehicleID, 30);
    vehicle.setNumberOfGears(vehicleID, 6);

    vehicle.setGearRatio(vehicleID, 2.2);
    vehicle.setGearRatio(vehicleID, 1.78);
    vehicle.setGearRatio(vehicleID, 1.3);
    vehicle.setGearRatio(vehicleID, 1);
    vehicle.setGearRatio(vehicleID, 0.74);
    vehicle.setGearRatio(vehicleID, 0.5);
    vehicle.setGearRatio(vehicleID, -1);

    vehicle.setRPM(vehicleID, 2000, 6500, 1000, 7000); -- vehicleIndex, minRpmToGearDown, maxRpmToGearUp, minRpm, maxRpm

    vehicle.setDownforce(vehicleID,-5000);
    vehicle.setNoWheelsDownforce(vehicleID,-5000);
    vehicle.setPairDownforce(vehicleID,-5000);

    -- Define the torque curve for the motor
    vehicle.setTorqueCurveSlot(vehicleID, 1000, 400);
    vehicle.setTorqueCurveSlot(vehicleID, 3000, 440);
    vehicle.setTorqueCurveSlot(vehicleID, 4000, 500);
    vehicle.setTorqueCurveSlot(vehicleID, 5000, 550);
    vehicle.setTorqueCurveSlot(vehicleID, 7000, 500);

    vehicle.setMaxSpeed_MPH(vehicleID, 97);
    vehicle.useAntiRoll(vehicleID, 1);

    vehicle.setAntiRollAmount(vehicleID, 2000); 

-- | Define the number of chassis components and Wheel components
-- | =======================================
    vehicle.setNumOfChassis(vehicleID, 2);
    vehicle.setNumberOfWheels(vehicleID, 4);

-- | Create the chassis components
-- | =======================================
    -- local positions of each chassis
    chPos0_X = 0; chPos0_Y = 0.6; chPos0_Z = 0; 
    chPos1_X = 0; chPos1_Y = 1.2; chPos1_Z = 0;


    -- scale in meters for how big the boxes are.
    chScale0_X = 2.1; chScale0_Y = 0.7; chScale0_Z = 4.0; 
    chScale1_X = 1.6; chScale1_Y = 0.5; chScale1_Z = 2.3;   

    vehicle.addChassis(vehicleID, 0, chPos0_X, chPos0_Y, chPos0_Z, chScale0_X, chScale0_Y, chScale0_Z);
    vehicle.addChassis(vehicleID, 1, chPos1_X, chPos1_Y, chPos1_Z, chScale1_X, chScale1_Y, chScale1_Z);

-- | Create the wheel components
-- | =======================================
    vehicle.setWheelMesh(vehicleID, wheelMesh); 

    wheelRadius = 0.35;
    wheelCounter = 0;

-- Front Wheels
    --FL
    vehicle.addWheel(vehicleID, wheelCounter, 0, 1, 0.80 , 0.42 , 1.75 );   
    vehicle.setWheelRadius(vehicleID, wheelCounter, wheelRadius); 
    wheelCounter = wheelCounter+1;
    --FR
    vehicle.addWheel(vehicleID, wheelCounter, 0, 1, -0.80, 0.42 , 1.75 );   
    vehicle.setWheelRadius(vehicleID, wheelCounter, wheelRadius); 
    wheelCounter = wheelCounter+1;

-- Rear Wheels
    --BL
    vehicle.addWheel(vehicleID, wheelCounter, 1, 0, 0.80 , 0.42 ,-1.35 );   
    vehicle.setWheelRadius(vehicleID, wheelCounter, wheelRadius); 
    vehicle.setWheelAsHandbrake(vehicleID, wheelCounter);   
    wheelCounter = wheelCounter+1;
    --BR
    vehicle.addWheel(vehicleID, wheelCounter, 1, 0, -0.80, 0.42 ,-1.35 );   
    vehicle.setWheelRadius(vehicleID, wheelCounter, wheelRadius); 
    vehicle.setWheelAsHandbrake(vehicleID, wheelCounter);   
    wheelCounter = wheelCounter+1;


-- Set the tire friction and suspension settings
    vehicle.setLatWheelFrictionSettings (vehicleID, 0, 0.04, 0.6, 0.01, 1, 6000);-- 5000);
    vehicle.setLongWheelFrictionSettings(vehicleID, 0, 0.04, 0.6, 0.01, 1, 8000);-- 8000);
    vehicle.setSuspensionSettings(vehicleID, 0, 2000, 30000, 0.0, 0.27);

    vehicle.setLatWheelFrictionSettings (vehicleID, 1, 0.04, 0.6, 0.01, 1, 6000);-- 5000);
    vehicle.setLongWheelFrictionSettings(vehicleID, 1, 0.04, 0.6, 0.01, 1, 8000);-- 8000);
    vehicle.setSuspensionSettings(vehicleID, 1, 2000, 30000, 0.0, 0.27);

    vehicle.setLatWheelFrictionSettings (vehicleID, 2, 0.04, 0.6, 0.01, 1, 4000);-- 3000);
    vehicle.setLongWheelFrictionSettings(vehicleID, 2, 0.04, 0.6, 0.01, 1, 10000);-- 10000);
    vehicle.setSuspensionSettings(vehicleID, 2, 2000, 30000, 0.0, 0.27);

    vehicle.setLatWheelFrictionSettings (vehicleID, 3, 0.04, 0.6, 0.01, 1, 4000);-- 3000);
    vehicle.setLongWheelFrictionSettings(vehicleID, 3, 0.04, 0.6, 0.01, 1, 10000);-- 10000);
    vehicle.setSuspensionSettings(vehicleID, 3, 2000, 30000, 0.0, 0.27);

-- | Finally create the body then the wheel meshes
-- | =======================================
    vehicle.createPhyicsBody(vehicleID);
    vehicle.createWheels( vehicleID );

end

function onStop(  )
    vehicle.destroy(vehicleID);
end

function onUpdate( timeDelta )
    if(wKeyDown == 1)then vehicle.accelerate(vehicleID);        end
    if(sKeyDown == 1)then vehicle.decelerate(vehicleID);        end

    if(aKeyDown == 1)then vehicle.steerLeft(vehicleID);         end
    if(dKeyDown == 1)then vehicle.steerRight(vehicleID);        end

    if(spaceKeyDown == 1)then vehicle.handBrake(vehicleID,3000); end
end



function onKeyDown( key )
    if(key == "w" or key == "up"    )then wKeyDown = 1; sKeyDown = 0;end
    if(key == "a" or key == "left"  )then aKeyDown = 1; dKeyDown = 0;end
    if(key == "s" or key == "down"  )then sKeyDown = 1; wKeyDown = 0;end
    if(key == "d" or key == "right" )then dKeyDown = 1; aKeyDown = 0;end

    if(key == "space")then spaceKeyDown = 1; end
end

function onKeyUp( key )
    if(key == "w" or key == "up"    )then wKeyDown = 0; end
    if(key == "a" or key == "left"  )then aKeyDown = 0; end
    if(key == "s" or key == "down"  )then sKeyDown = 0; end
    if(key == "d" or key == "right" )then dKeyDown = 0; end

    if(key == "space")then spaceKeyDown = 0; end
end

For more information on how these functions can be used please visit the User Manual - https://home.aurasoft-skyline.co.uk

Vehicle Specifics

        Forwards 
           |
           |
          ___
        ||   ||
         |   |
Side --  |   |
        ||___||

Member Function Documentation

void vehicle::accelerate ( int  vehicleID)
void vehicle::addChassis ( int  vehicleID,
int  chassisIndex,
float posXfloat  posY,
float  posZ,
float  scaleX,
float  scaleY,
float  scaleZ 
)
void vehicle::addWheel ( int  vehicleID,
int  vehicleID,
int  wheelIndex,
int  driveWheel,
int  steerWheel,
float  posX,
float  posY,
float  posZ 
)
void vehicle::applyForce ( int  vehicleID,
float  axizX,
float  axizY,
float  axizZ 
)
void vehicle::applyForceAtPoint ( int  vehicleID,
float  axizX,
float  axizY,
float  axizZ,
float  posX,
float  posY,
float  posZ 
)
void vehicle::applyLocalForce ( int  vehicleID,
float  axizX,
float  axizY,
float  axizZ 
)

Apply a local force to the center of the vehicle.

Parameters
vehicleID: The ID of the vehicle.
forceAxisX: The force to apply in the X Axis.
forceAxisY: The force to apply in the Y Axis.
forceAxisZ: The force to apply in the Z Axis.

The following is a Small Example on how to use this function:

function onInit(objID)
    -- apply a negative Y Axis force at 1 meter above the cars pivot.
    vehicle.applyLocalForceAtPoint( vehID, 0, -200, 0, 0, 1, 0 );
end
void vehicle::applyLocalForceAtPoint ( int  vehicleID,
float  axizX,
float  axizY,
float  axizZ,
float  posX,
float  posY,
float  posZ 
)

Apply a local force at a particular point on the vehicle.

Parameters
vehicleID: The ID of the vehicle.
forceAxisX: The force to apply in the X Axis.
forceAxisY: The force to apply in the Y Axis.
forceAxisZ: The force to apply in the Z Axis.
posAxisX: The position to apply the force on the X Axis.
posAxisY: The position to apply the force on the X Axis.
posAxisZ: The position to apply the force on the X Axis.

The following is a Small Example on how to use this function:

function onInit(objID)
    -- apply a negative Y Axis force at 1 meter above the cars pivot.
    vehicle.applyLocalForceAtPoint( vehID, 0, -200, 0, 0, 1, 0 );
end
void vehicle::createPhyicsBody ( int  vehicleID)
void vehicle::createVehicle ( string  vehicleName,
int  sceneEntityID,
float  posX,
float  posY,
float  posZ,
float  rotW,
float  rotX,
float  rotY,
float  rotZ 
)

create a new scripted vehicle to work on. It will need setup with the correct functions.

Order of scripted vehicle creation

  • spawn entity or use entity in scene.
  • call vehicle.createVehicle function to create a new base vehicle.
  • Call setup commands like addChassis, addWheel, setWheelMesh.
  • create the vehicle physics body with vehicle.createPhyicsBody( vehicleID);
  • create the wheels physics with vehicle.createWheels( vehicleID );

Note: this function should be called first before any other vehicle setup commands.

Parameters
vehicleName: The name of this vehicle. it must be unique.
sceneEntityID: The ID of the sceneEntity you wish to make into a vehicle.
posX: Set the position Axis X of where to place the vehicle.
posY: Set the position Axis Y of where to place the vehicle.
posZ: Set the position Axis Z of where to place the vehicle.
rotW: Set the Orientation of the vehicle on the W axis.
rotX: Set the Orientation of the vehicle on the X axis.
rotY: Set the Orientation of the vehicle on the Y axis.
rotZ: Set the Orientation of the vehicle on the Z axis.
Returns
vehID The following is a Small Example on how to use this function:
function onInit(objID)
    vehID = vehicle.createVehicle( "vehicleName", obj, 0, 0, 0, 0, 0, 0, 0);
end
void vehicle::createWheels ( int  vehicleID)
void vehicle::decelerate ( int  vehicleID)
void vehicle::destroy ( int  vehicleID)

Destroy and cleanup a vehicle in the scene by the vehicle ID passed through this function You should only destroy id's that are active in the scene.

The following is a Small Example on how to use this function:

function onInit(objID)
    vehID = vehicle.destroy( vehID );
end
void vehicle::enableAutoMaxSteer ( int  vehicleID,
int  state 
)

Sets the steering to auto adjust based on speed and reduce the steering angle.

Parameters
vehicleID: The ID of the vehicle.
state: 1 = true, 0 = false

The following is a Small Example on how to use this function:

function onInit(objID)
    vehicle.enableAutoMaxSteer( vehID, 1 );
end
void vehicle::followPath ( int  vehicleID,
string  pathName,
float  throttle 
)

follow a path simply by calling this function in an update loop.
The movement will automatically be smoothed out based on the setPathAccuracy() accuracy variable.

Parameters
vehicleID: This is the id of the vehicle.
pathname: The path to follow, change the name on the fly to start following another path without position stepping.
throttle: How far the throttle on the car is pressed. 1 - full speed, 0 - no speed This variable already uses timedelta in the system to keep framerate in check.

Here is a Small Example of how to use this function:

function onUpdate(timeDelta)
    vehicle.followPath(vehicleID, pathName, 5);
end

Yes, thats all thats needed to follow a path accurately and very fast. =)

void vehicle::followPathPosition ( int  vehicleID,
float  x,
float  y,
float  z 
)

Override the default path follow and enter your own point to move to.
In order for this to take effect, you need to pass a "" in the follow path function. See the example below.

Calling this function on its own will result in nothing happening, it has to be used in conjunction with vehicle.followPath()

Parameters
vehicleID: This is the id of the vehicle.
x: This is the x world position axis. Is defined as a float
y: This is the y world position axis. Is defined as a float
z: This is the z world position axis. Is defined as a float

Here is a Small Example of how to use this function:

function onInit(objID)
    vehicle.followPathPosition(vehicleID, posArray[0].x, posArray[0].y, posArray[0].z );
end

function onUpdate(timeDelta)
    if(vehicle.isDestinationReached(vehicleID) == 1)then
        posIndex = posIndex + 1;
        newPos = newType.vec3(posArray[posIndex].x, posArray[posIndex].y, posArray[posIndex].z);
        vehicle.followPathPosition(vehicleID, newPos.x, newPos.y, newPos.z );
    end
    
    vehicle.followPath(vehicleID, "", 5.0f); -- set path blank as you do not need one.

end
int vehicle::getActiveVehicleID ( )
int vehicle::getAutoMaxSteerEnabled ( int  vehicleID)

Gets whether the steering angle auto reduces based on speed.

Parameters
vehicleID: The ID of the vehicle.
Returns
isEnabled : This is 1 or 0 value for true or false

The following is a Small Example on how to use this function:

function onInit(objID)
    isEnabled = vehicle.getAutoMaxSteerEnabled( vehID );
end
int vehicle::getCurrentGear ( int  vehicleID)
float vehicle::getCurrentThrottle ( int  vehicleID)
string vehicle::getFollowPathName ( int  vehicleID)

return the name of the path the vehicle is following

Parameters
vehicleID: This is the id of the vehicle.
Returns
pathName : This is the pathname that will be returned.

Here is a Small Example of how to use this function:

function onUpdate(timeDelta)
    pathname = vehicle.getFollowedPathName(vehicleID);
end
float vehicle::getMaxBrakeForce ( int  vehicleID)
int vehicle::getMaxSpeed_KPH ( int  vehicleID)
int vehicle::getMaxSpeed_MPH ( int  vehicleID)
int vehicle::getMoveDirection ( int  vehicleID)

#brief return the direction is moving

0 - forwards 1 - reverse 2 - neutral

int vehicle::getNumOfChassis ( int  vehicleID)
int vehicle::getNumOfWheels ( int  vehicleID)
int vehicle::getRPM ( int  vehicleID)
int vehicle::getSpeed_Kph ( int  vehicleID)
int vehicle::getSpeed_Mph ( int  vehicleID)
float vehicle::getSteeringMulti ( int  vehicleID)

Set the multiplier between 1 and 0 to reduce the steering input. Useful for joysticks.

Parameters
vehicleID: The ID of the vehicle.
Returns
multi : A value between 1 and 0 (0.2, 0.6 etc..) that reduces the amount of steering input.

The following is a Small Example on how to use this function:

function onInit(objID)
    multi = vehicle.getSteeringMulti( vehID );
end
vehicle vehicle::getTagOffset ( vehID  ,
wheelID   
)

Get TAG offset.

Parameters
vehicleID: This is the id of the vehicle to poll from.
wheelID:
offset:
int vehicle::getVehicleID ( int  sceneEntityID,
string  vehicleName 
)

Get the ID of a vehicle by passing the scene entity ID and a vehicle Name.

Note: vehicleName is depreciated

The following is a Small Example on how to use this function:

function onInit(objID)
    vehID = vehicle.getVehicleID( obj, "" );
end
int vehicle::getVelocity ( int  vehicleID)
float vehicle::getWheel_ContactForce ( int  vehicleID,
int  wheelIndex 
)

Return the contact force data from the specified wheel.

Parameters
vehicleID: The ID of the vehicle.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
force : This is the returned force of the wheel contact data.

The following is a Small Example on how to use this function:

function onInit(objID)
    force = vehicle.getWheel_ContactForce( vehID, 0 );
end
int vehicle::getWheel_ContactGround ( int  vehicleID,
int  wheelIndex 
)

Get if the wheel specified is in contact with the ground and return a 1 or 0 boolean.

Parameters
vehicleID: The ID of the vehicle.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
hasContact : 1 = true; 0 = false; Returns whether the wheel is in contact with the ground.

The following is a Small Example on how to use this function:

function onInit(objID)
    hasContact = vehicle.getWheel_ContactGround( vehID, 0 );
end
float3 vehicle::getWheel_ContactNormal ( int  vehicleID,
int  wheelIndex 
)

Return the contact Normal from the specified wheel. This is the normal of the raycasted face.

Parameters
vehicleID: The ID of the vehicle.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
normalX : The returned normals X axis. This is a tangent of the face.
normalY : The returned normals Y axis. This is the normal angle of the raycasted face.
normalZ : The returned normals Z axis. This is a tangent of the face.

The following is a Small Example on how to use this function:

function onInit(objID)
    normalX, normalY, normalZ = vehicle.getWheel_ContactNormal( vehID, 0 );
end
float3 vehicle::getWheel_ContactPoint ( int  vehicleID,
int  wheelIndex 
)

Get the point of contact with the floor and bottom of the wheel in world space.

Parameters
vehicleID: The ID of the vehicle.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
posX : The returned point of contact position with the floor on the World X Axis;
posY : The returned point of contact position with the floor on the World Y Axis;
posZ : The returned point of contact position with the floor on the World Z Axis;

The following is a Small Example on how to use this function:

function onInit(objID)
    posX, posY, posZ = vehicle.getWheel_ContactPoint( vehID, 0 );
end
float vehicle::getWheel_ContactPosition ( int  vehicleID,
int  wheelIndex 
)

Return the position of suspensionTravel between 0(not extended) and 1(fully extended).

Parameters
vehicleID: The ID of the vehicle.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
suspPos : This is the returned suspension position between 0 and 1.
Suspension Example:

0  ---- Not Extended Suspension
    ||
    ||
    ||
--  || Returned Current Position : "0.5" (example value)
    ||
    ||
    ||
1  ---- Fully Extended Suspension

The following is a Small Example on how to use this function:

function onInit(objID)
    suspPos = vehicle.getWheel_ContactPosition( vehID, 0 );
end
float3 vehicle::getWheel_LateralDirection ( int  vehicleID,
int  wheelIndex 
)

get the contact data of the specified wheel and retrieve the LateralDirection

Parameters
vehicleID: The ID of the vehicle.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
lateralDirection : This is the direction the wheel is pointing in for the forward direction.

The following is a Small Example on how to use this function:

function onInit(objID)
    lateralDirection = vehicle.getWheel_LateralDirection( vehID, 0 );
end
float vehicle::getWheel_LateralImpulse ( int  vehicleID,
int  wheelIndex 
)

get the contact data of the specified wheel and retrieve the LateralImpulse value.

Parameters
vehicleID: The ID of the vehicle.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
lateralImpulse : This is the clipped impulses applied at the wheel in the sideways direction.

The following is a Small Example on how to use this function:

function onInit(objID)
    latImpulse = vehicle.getWheel_LongitudalImpulse( vehID, 0 );
end
float vehicle::getWheel_LateralSlip ( int  vehicleID,
int  wheelIndex 
)

get the contact data of the specified wheel and retrieve the LateralSlip angle value.

Parameters
vehicleID: The ID of the vehicle you wish to return the slip from.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
lateralSlip : This is the slip angle of the wheel in the sideways direction.

The following is a Small Example on how to use this function:

function onInit(objID)
    latSlip = vehicle.getWheel_LateralSlip( vehID, 0 );
end
float3 vehicle::getWheel_LongitudalDirection ( int  vehicleID,
int  wheelIndex 
)

get the contact data of the specified wheel and retrieve the LongitudalDirection

Parameters
vehicleID: The ID of the vehicle you wish to return the slip from.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
longDirection : This is the direction the wheel is pointing in for the forward direction.

The following is a Small Example on how to use this function:

function onInit(objID)
    longDirection = vehicle.getWheel_LongitudalDirection( vehID, 0 );
end
float vehicle::getWheel_LongitudalImpulse ( int  vehicleID,
int  wheelIndex 
)

get the contact data of the specified wheel and retrieve the LongitudalImpulse value.

Parameters
vehicleID: The ID of the vehicle you wish to return the slip from.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
longitudalImpulse : This is the clipped impulses applied at the wheel on the forward direction.

The following is a Small Example on how to use this function:

function onInit(objID)
    longImpulse = vehicle.getWheel_LongitudalImpulse( vehID, 0 );
end
float vehicle::getWheel_LongitudalSlip ( int  vehicleID,
int  wheelIndex 
)

get the contact data of the specified wheel and retrieve the LongitudalSlip angle value.

Parameters
vehicleID: The ID of the vehicle you wish to return the slip from.
wheelIndex: The ID of the wheel in which to retrieve the contact data.
Returns
longitudalSlip : This is the slip ratio of the vehicle for the forwards direction.

The following is a Small Example on how to use this function:

function onInit(objID)
    longSlip = vehicle.getWheel_LongitudalSlip( vehID, 0 );
end
float3 vehicle::getWheelGlobalPosition ( int  vehicleID,
int  wheelIndex 
)
float3 vehicle::getWheelLocalPosition ( int  vehicleID,
int  wheelIndex 
)
string vehicle::getWheelMesh ( int  vehicleID)
float vehicle::getWheelRadius ( int  vehicleID,
int  wheelIndex 
)
void vehicle::handBrake ( int  vehicleID,
float  torque 
)
int vehicle::isDestinationReached ( int  vehicleID)

Poll to check if the vehicle has reached its destination.

Parameters
vehicleID: This is the id of the vehicle to poll from.

Here is a Small Example of how to use this function:

function onUpdate(timeDelta)
    if(vehicle.isDestinationReached(vehicleID) == 1)then
        sky.print("detination has been reached.. change position to run to.");
    end
end
int vehicle::isFollowingPath ( int  vehicleID)

return whether the vehicle is currently following a path.

Parameters
vehicleID: This is the id of the vehicle.
Returns
isFollowing : This is an integer value representing a boolean. 1 = true, 0 = false

Here is a Small Example of how to use this function:

function onUpdate(timeDelta)
    isFollowingPath = vehicle.isFollowingPath(vehicleID);
end
int vehicle::isPlayer ( int  vehicleID)
void vehicle::setAirResistance ( int  vehicleID,
float  baseValue,
float  multiplier 
)
void vehicle::setAngularDamping ( int  vehicleID,
float  damp 
)
void vehicle::setAngularMomentum ( int  vehicleID,
float  x,
float  y,
float  z 
)
void vehicle::setAngularVelocity ( int  vehicleID,
float  x,
float  y,
float  z 
)
void vehicle::setAntiRollAmount ( int  vehicleID,
float  antiRollAmt 
)
void vehicle::setAsPlayer ( int  vehicleID,
int  isPlayer[1 or 0] 
)
void vehicle::setBrakeTorque ( int  vehicleID,
int  wheelIndex,
float  torque 
)
void vehicle::setCenterOfMass ( int  vehicleID,
float  offsetX,
float  offsetY,
float  offsetZ 
)
void vehicle::setCurrentGear ( int  vehicleID,
int  gear 
)
void vehicle::setCurrentThrottle ( int  vehicleID,
float  throttle 
)
void vehicle::setCustomDebugMaterial ( int  vehicleID,
string  customDebugMaterialName 
)
void vehicle::setDownforce ( int  vehicleID,
float  downforce 
)
void vehicle::setGearRatio ( int  vehicleID,
float  gearRatio 
)
void vehicle::setInverseWheelMass ( int  vehicleID,
int  wheelIndex,
float  amt 
)
void vehicle::setLatWheelFrictionSettings ( int  vehicleID,
int  wheelIndex,
float  asymptoteSlip,
float  asymptoteValue,
float  extremumSlip,
float  extremumValue,
float  stiffnessFactor 
)
void vehicle::setLatWheelFrictionStiffness ( int  vehicleID,
int  wheelIndex,
float  stiffnessFactor 
)
void vehicle::setLength ( int  vehicleID,
int  soundEnumSection,
float  length 
)
void vehicle::setLinearDamping ( int  vehicleID,
float  damp 
)
void vehicle::setLinearMomentum ( int  vehicleID,
float  x,
float  y,
float  z 
)
void vehicle::setLinearVelocity ( int  vehicleID,
float  x,
float  y,
float  z 
)
void vehicle::setLongWheelFrictionSettings ( int  vehicleID,
int  wheelIndex,
float  asymptoteSlip,
float  asymptoteValue,
float  extremumSlip,
float  extremumValue,
float  stiffnessFactor 
)
void vehicle::setLongWheelFrictionStiffness ( int  vehicleID,
int  wheelIndex,
float  stiffnessFactor 
)
void vehicle::setLooped ( int  vehicleID,
int  soundEnumSection,
int  isLooped[0 or 1] 
)
void vehicle::setMass ( int  vehicleID,
float  mass 
)
void vehicle::setMaxSpeed_KPH ( int  vehicleID,
int  maxSpeedKPH 
)
void vehicle::setMaxSpeed_MPH ( int  vehicleID,
int  maxSpeedMPH 
)
void vehicle::setMaxSteeringAngle ( int  vehicleID,
float  angle 
)
void vehicle::setMotorTorque ( int  vehicleID,
int  wheelIndex,
float  torque 
)
void vehicle::setNoWheelsDownforce ( int  vehicleID,
float  downforce 
)
void vehicle::setNumberOfGears ( int  vehicleID,
int  numGears 
)
void vehicle::setNumberOfWheels ( int  vehicleID,
int  numWheels 
)
void vehicle::setNumOfChassis ( int  vehicleID,
int  chassisNum 
)
void vehicle::setOrientation ( int  vehicleID,
float  rotW,
float  rotX,
float  rotY,
float  rotZ 
)
void vehicle::setPairDownforce ( int  vehicleID,
float  downforce 
)
void vehicle::setPathAccuracy ( int  vehicleID,
float  accuracy 
)

Set the accuracy of the path to follow. Lower numbers make the distance to each node before trigger smaller.

Parameters
vehicleID: This is the id of the vehicle.
accuracy: This number increases the distance allowed to the wanted node before it triggers to move to the next.
If a vehicle travels faster, then you will want a larger accuracy to catch them from going off the path and also a faster rotation.

Here is a Small Example of how to use this function:

function onUpdate(timeDelta)
    vehicle.setPathAccuracy(vehicleID, 10);
    vehicle.followPath(vehicleID, pathName, 5);
end
void vehicle::setPathMaxTurn ( int  vehicleID,
float  maxTurn 
)

Set the maximum speed of the turning rate for this vehicle.

Parameters
vehicleID: This is the id of the vehicle.
maxTurn: This number increases the speed of rotation to make the vehicle more responsive.
Higher numbers will make the vehicle stick closer to the path lines. Lower numbers make it turn more gently.

Here is a Small Example of how to use this function:

function onUpdate(timeDelta)
    vehicle.setPathMaxTurn(vehicleID, 5.0);
    vehicle.followPath(vehicleID, pathName, 5);
end
void vehicle::setPathNodeIndex ( int  vehicleID,
int  nodeIndex 
)

Set the current node index the vehicle should head towards on the currently set path.

Parameters
vehicleID: This is the id of the vehicle.
nodeIndex: Set the node index of the path to move to, it will then carry on sequentially.

Here is a Small Example of how to use this function:

function onUpdate(timeDelta)
    vehicle.setPathNodeIndex(vehicleID, 2);
    vehicle.followPath(vehicleID, pathName, 5);
end
void vehicle::setPitch ( int  vehicleID,
int  soundEnumSection,
float  pitch 
)
void vehicle::setPosition ( int  vehicleID,
float  posX,
float  posY,
float  posZ 
)
void vehicle::setRPM ( int  vehicleID,
int  minRpmToGearDown,
int  maxRpmToGearUp,
int  minRpm,
int  maxRpm 
)
void vehicle::setSound ( int  vehicleID,
int  soundEnumSection,
string  soundFile 
)
void vehicle::setSteeringCoefMulti ( int  vehicleID,
float  coeff 
)
void vehicle::setSteeringMulti ( int  vehicleID,
float  multi 
)

Set the multiplier between 1 and 0 to reduce the steering input. Useful for joysticks.

Parameters
vehicleID: The ID of the vehicle.
multi: A value between 1 and 0 (0.2, 0.6 etc..) that reduces the amount of steering input.

The following is a Small Example on how to use this function:

function onInit(objID)
    vehicle.setSteeringMulti( vehID, 0.5 ); -- Sets half the maximum turn speed
end
void vehicle::setSuspensionSettings ( int  vehicleID,
int  wheelIndex,
float  damperAmt,
float  springAmt,
float  targetValue,
float  suspensionTravel 
)
vehicle vehicle::setTagOffset ( vehID  ,
wheelID  ,
offset   
)

Set TAG offset.

Parameters
vehicleID: This is the id of the vehicle to poll from.
wheelID:
offset:
void vehicle::setTorqueCurveSlot ( int  vehicleID,
int  rpm,
int  torque 
)
void vehicle::setVolume ( int  vehicleID,
int  soundEnumSection,
float  volume 
)
void vehicle::setWheelAsHandbrake ( int  vehicleID,
int  wheelIndex 
)
void vehicle::setWheelMesh ( int  vehicleID,
string  wheelMeshName 
)
void vehicle::setWheelParticle ( int  vehicleID,
int  wheelIndex,
string  particleName 
)
void vehicle::setWheelParticleEnabled ( int  vehicleID,
int  wheelIndex,
int  isEnabled[0 or 1] 
)
void vehicle::setWheelParticlePosition ( int  vehicleID,
int  wheelIndex,
float  x,
float  y,
float  z 
)
void vehicle::setWheelRadius ( int  vehicleID,
int  wheelIndex,
float  radius 
)
void vehicle::showDebug ( int  vehicleID,
int  showDebug[0 or 1] 
)
void vehicle::steerLeft ( int  vehicleID,
int  overrideSteering,
float  steeringAngle 
)

Calling this command will make the vehicle steer left either by the engine itself or a custom steer angle of your choice.

Parameters
vehicleID: This is the id of the vehicle to steer
overrideSteering: 1 - override default steering. 0 - use engine based steering. This is an optional parameter.
steeringAngle: Set the new steering angle of all steerable wheels. is an optional parameter and must have overrideSteering set to 1.

If you override the steering or stop calling the command, then you will need to steer the vehicle back in line yourself.

void vehicle::steerRight ( int  vehicleID,
int  overrideSteering,
float  steeringAngle 
)

Calling this command will make the vehicle steer left either by the engine itself or a custom steer angle of your choice.

Parameters
vehicleID: This is the id of the vehicle to steer
overrideSteering: 1 - override default steering. 0 - use engine based steering. This is an optional parameter.
steeringAngle: Set the new steering angle of all steerable wheels. is an optional parameter and must have overrideSteering set to 1.

If you override the steering or stop calling the command, then you will need to steer the vehicle back in line yourself.

void vehicle::useAirResistance ( int  vehicleID,
int  useResistance[0 or 1] 
)
void vehicle::useAntiRoll ( int  vehicleID,
int  useAntiRoll[0 or 1] 
)
void vehicle::useSound ( int  vehicleID,
int  soundEnumSection,
int  useSound[0 or 1] 
)
void vehicle::useWheelParticle ( int  vehicleID,
int  wheelIndex,
int  useParticle[0 or 1] 
)

The documentation for this class was generated from the following file: