Path: MoveAlongSection

Moves an object along a specified section of a path at a given speed and direction, optionally invoking a callback function when the object reaches the end of the section.

Note: Currently, this function is metric-only (e.g., units in meters, not feet), regardless of the project’s default unit system.

Function

void MoveAlongSection(
    sectionId: integer, 
    obj: object, 
    speed: number, 
    acceleration: number, 
    deceleration: number, 
    backward: boolean, 
    offset: number)

Parameters

Name Type Description
sectionId Integer The 1-based index of the section within the path that the object should follow
obj Object The object to be moved along the Path
speed Number The maximum speed (in meters per second) the object will reach during movement
acceleration Number The rate at which the object accelerates from 0 to the specified speed
deceleration Number The rate at which the object decelerates from its current speed to 0 when approaching the end of the section
backward Boolean If true, the object moves in reverse along the section
offset Number Reserved for future use. Currently ignored.

Return Value

None. However, a callback can be invoked once movement is complete (see examples).

Example

var path1;
var path2;
var ob1;
var ob2;

function OnSimulationStart()
{
    LogDebug("OnSimulationStart called");
    
    ob1 = GetComponentByNameAndType ('BasicShape1', "Basic Shape");
    ob2 = GetComponentByNameAndType ('BasicShape2', "Basic Shape");
    
    path1 = GetComponentByNameAndType ('Path1', "Path");
    path2 = GetComponentByNameAndType ('Path2', "Path");
    
    path1.MoveAlongSection(1, ob1, 10.0, 0.0, 0.0, false, Noop);
    path2.MoveAlongSection(1, ob2, 5.0, 0.0, 0.0, true, Noop); 
}

function Noop(sender,sectionID,object,backward)
{
    LogDebug("Noop: " + index);
    LogDebug("X: " + object.X + " Y: " + object.Y + " Z: " + object.Z); 
}

Another example:

var path1;
var ob1;

function OnSimulationStart()
{
    LogDebug("OnSimulationStart called");
    
    ob1 = GetComponentByNameAndType ('BasicShape1', "Basic Shape"); 
    path1 = GetComponentByNameAndType ('Path1', "Path");
    
    path1.MoveAlongSection(1, ob1, 10.0, 0.0, 0.0, false, null);
}