Path: MoveAlongSectionWithDistance

Called to move an object along section for a certain distance and callback the function once reached the distance.

Note that this function is metric only for the moment.

Function

void MoveAlongSectionWithDistance(
    sectionId: integer, 
    obj: object, 
    speed: number, 
    acceleration: number, 
    deceleration: number, 
    backward: boolean, 
    distance: double, 
    callback: function)
void MoveAlongSectionWithDistance(
    sectionId: integer, 
    obj: object, 
    speed: number, 
    acceleration: number, 
    deceleration: number, 
    backward: boolean, 
    distance: double, 
    callback: function, 
    resetAfterFinished: boolean)

Parameters

Name Type Description
sectionId Integer Id of the section. One based
obj Object Object to be moved on the section
speed Number Max speed in the units chosen when the project was created (metres or feet)
acceleration Number Acceleration from 0 to max speed
deceleration Number Deceleration from max speed to 0
backward Boolean Boolean to indicate if running backward
distance Double Specific distance to move the object along path
callback Function Callback function that will be called when the movement is complete. Pass null if no callback is required.

There is only one callback per path! Subsequent calls to this function will overwrite the callbacks previously passed, and passing null will remove a previously registered callback.
resetAfterFinished Boolean Boolean to reset object when movement is finished. When set to true, next movement call of same section and object will begin movement from section start. Default value is false

Return Value

None

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.MoveAlongSectionWithDistance(1, ob1, 10.0, 0.0, 0.0, false,10.0, Noop);
    path2.MoveAlongSectionWithDistance(1, ob2, 5.0, 0.0, 0.0, true,7.0, 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.MoveAlongSectionWithDistance(1, ob1, 10.0, 0.0, 0.0, false,10.0, null);
}