Physics Basic Shape: GoToPosition
Move the shape until it is at the specified position.
Only one movement can be performed at a time. If this function is called before a previous movement has completed, the first movement will stop where it is, and the new movement will start from that position.
All positions, speeds, and units are in project units. That is to say, the distance, speed, and acceleration is meters, meters/second, and meters/second^2 for metric projects, and feet, feet/second, and feet/second^2 for imperial projects.
Function
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed);
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed, xAcc, xDec, yAcc, yDec, zAcc, zDec);
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction);
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, xAcc, xDec, yAcc, yDec, zAcc, zDec);
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, CallbackInterval);
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, CallbackInterval, xAcc, xDec, yAcc, yDec, zAcc, zDec);
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, intOffsetArray);
void GoToPosition(x, y, z, xSpeed, ySpeed, zSpeed,CallbackFunction, intOffsetArray, xAcc, xDec, yAcc, yDec, zAcc, zDec);
Parameters
Name | Type | Description |
---|---|---|
x | Number | The X coordinate of the target position |
y | Number | The Y coordinate of the target position |
z | Number | The Z coordinate of the target position |
xSpeed | Number | The speed along the X axis |
ySpeed | Number | The speed along the Y axis |
zSpeed | Number | The speed along the Z axis |
CallbackFunction | function(sender, x, y, z) | Callback function will be called with the shape and the coordinates. |
CallbackInterval | Number | Interval in milliseconds when callback function is called over the course of the movement. |
intOffsetArray | Array | Array of integer values in milliseconds. The callback function is called when the movement is that many milliseconds before completion. |
xAcc | Number | Acceleration of X axis |
xDec | Number | Deceleration of X axis |
yAcc | Number | Acceleration of Y axis |
yDec | Number | Deceleration of Y axis |
zAcc | Number | Acceleration of Z axis |
zDec | Number | Deceleration of Z axis |
Example
function OnSimulationStart()
{
let shape = GetComponentByNameAndType("PhysicsBasicShape1", "Physics Basic Shape");
shape.GoToPosition(20, 30, 40, 5, 3, 2, OnMovementComplete);
}
function OnMovementComplete(sender, x, y, z)
{
LogDebug(`${sender.Name} = ${x} ${y} ${z}`);
}