MotionBehaviour

class Varwin.MotionBehaviour

Bases: object

class Axis

Bases: object

X: Any = Ellipsis
Y: Any = Ellipsis
Z: Any = Ellipsis
class LockRotationRules

Bases: object

Lock: Any = Ellipsis
OnlyHorizontal: Any = Ellipsis
AllowAll: Any = Ellipsis
TeleportTo(target: Object) None

Instantly moves the specified object to the coordinates of the second object.

Parameters:

(Object) (target) – scene object

Example:

instance.MotionBehaviour.TeleportTo(sceneObject1)
SetPosition(targetPosition: Vector3) None

Instantly moves the specified object to a position set by world space coordinates.

Example:

instance.MotionBehaviour.SetPosition(Varwin.Vector3(1,0,0))
MoveByAxisWithSpeed(axis: Vector3, speed: float) None

Starts the moving process of the specified object in the direction of the selected axis at the specified speed. The movement continues until it is stopped by the movement stop block. Use negative speed values to change the moving direction.

Example:

instance.MotionBehaviour.MoveByAxisWithSpeed(Varwin.Vector3(1,0,0), 0)
async MoveByAxisAtDistance(axis: Vector3, distance: float, speed: float) None

Starts the moving process of the specified object in the direction of the selected axis by the specified distance at the specified speed. The movement continues until the object covers the distance. Use negative speed values to change the moving direction.

Example:

await instance.MotionBehaviour.MoveByAxisAtDistance(Varwin.Vector3(1,0,0), 0, 0)
async MoveByAxisOverTime(axis: Vector3, duration: float, speed: float) None

Starts the moving process of the specified object in the direction of the selected axis for the specified time at the specified speed. Moving continues until the time has run out. Use negative speed values to change the moving direction.

Example:

await instance.MotionBehaviour.MoveByAxisOverTime(Varwin.Vector3(1,0,0), 0, 0)
async MoveToObjectAtSpeed(target: Object, speed: float) None

Starts the moving process of the specified object in the direction of the second object at the specified speed. The movement continues until the specified object reaches the second object.

Parameters:

(Object) (target) – scene object

Example:

await instance.MotionBehaviour.MoveToObjectAtSpeed(sceneObject1, 0)
async MoveToCoordinatesAtSpeed(target: Vector3, speed: float) None

Starts the moving process of the specified object in the direction of the specified coordinates at the specified speed. The movement continues until the object reaches the coordinates.

Example:

await instance.MotionBehaviour.MoveToCoordinatesAtSpeed(Varwin.Vector3(1,0,0), 0)
async MoveAlongThePath(path: List[Object | Vector3], speed: float) None

Starts the moving process of the specified object along the path at the specified speed. A route is a list of objects or coordinates in world space defined by vectors.

Example:

await instance.MotionBehaviour.MoveAlongThePath("test", 0)
Stop() None

Controls any movement. The paused movement can be resumed with the “Continue” block.

Example:

instance.MotionBehaviour.Stop()
Pause() None

Controls any movement. The paused movement can be resumed with the “Continue” block.

Example:

instance.MotionBehaviour.Pause()
Continue() None

Controls any movement. The paused movement can be resumed with the “Continue” block.

Example:

instance.MotionBehaviour.Continue()
IsMovingNow() bool

Returns true if the specified object is moving. Otherwise returns false.

Example:

result = instance.MotionBehaviour.IsMovingNow()
GetDistanceToObject(target: Object) float

Returns the straight-line distance from the specified object to the second object. The distance is returned in meters as a real number.

Parameters:

(Object) (target) – scene object

Example:

result = instance.MotionBehaviour.GetDistanceToObject(sceneObject1)
GetDistanceToVector(target: Vector3) float

Returns the straight-line distance from the specified object to world coordinates specified with a vector. The distance is returned in meters as a real number.

Example:

result = instance.MotionBehaviour.GetDistanceToVector(Varwin.Vector3(1,0,0))
property Position: Vector3

Returns the position of the specified object in world coordinates as a vector [x; y; z]

Example:

result = instance.MotionBehaviour.Position
property PositionX: float

Returns the position of the specified object along the selected axis in world coordinates.

Example:

result = instance.MotionBehaviour.PositionX
property PositionY: float

Returns the position of the specified object along the selected axis in world coordinates.

Example:

result = instance.MotionBehaviour.PositionY
property PositionZ: float

Returns the position of the specified object along the selected axis in world coordinates.

Example:

result = instance.MotionBehaviour.PositionZ
property MovementFaceDirection: Vector3

Sets the side of the object that it will be facing in the direction of the move.

Example:

result = instance.MotionBehaviour.MovementFaceDirection
property MinimumTargetStopDistance: float

Sets the minimum distance between the specified and target objects for movement to be considered complete. The block calculates the distance between the centers of the objects, so using a 0 value is not recommended.

Example:

result = instance.MotionBehaviour.MinimumTargetStopDistance
AddMovementFinishedHandler(handler: Callable[[Object], CoroutineType]) None

The event is triggered when the specified object completes any movement. The movement is considered completed if the object has reached the target position or if the movement has been stopped by the corresponding block. The object for which the event was triggered is passed to the parameter.

Parameters:

handler

Asynchronous handler function with signature:

  • sender (Object): the object that triggered the event

Example:

async def OnMovementFinished(sender):
  ...
instance.MotionBehaviour.AddMovementFinishedHandler(OnMovementFinished)
AddToWrapperMovementFinishedHandler(handler: Callable[[Object, Object], CoroutineType]) None

The event is triggered when the specified object completes moving to the target object. The object for which the event was triggered (moving object) and the object to which the movement was completed (target object) are passed in parameters.

Parameters:

handler

Asynchronous handler function with signature:

  • target (Object): target object

  • sender (Object): the object that triggered the event

Example:

async def OnToWrapperMovementFinished(target, sender):
  ...
instance.MotionBehaviour.AddToWrapperMovementFinishedHandler(OnToWrapperMovementFinished)
AddToVectorMovementFinishedHandler(handler: Callable[[Vector3, Object], CoroutineType]) None

The event is triggered when the specified object completes moving to the target coordinates. The object for which the event was triggered (moving object) and the coordinates as vector to which the movement was completed (target coordinates) are passed in parameters.

Parameters:

handler

Asynchronous handler function with signature:

  • target (Vector3): target coordinates

  • sender (Object): the object that triggered the event

Example:

async def OnToVectorMovementFinished(target, sender):
  ...
instance.MotionBehaviour.AddToVectorMovementFinishedHandler(OnToVectorMovementFinished)
AddWaypointReachedHandler(handler: Callable[[int, Any, Object], CoroutineType]) None

The event is triggered when the specified object moving along the path reaches a waypoint on the path. The parameters pass the object for which the event was triggered, the number of the waypoint, and the point reached.

Parameters:

handler

Asynchronous handler function with signature:

  • wayPointIndex (int): waypoint number

  • waypoint (Any): waypoint reached

  • sender (Object): the object that triggered the event

Example:

async def OnWaypointReached(wayPointIndex, waypoint, sender):
  ...
instance.MotionBehaviour.AddWaypointReachedHandler(OnWaypointReached)