Moving
A set of universal blocks, working with the Varwin objects motion setup. You can adjust the object’s position both in the 3D scene editing mode and in the Blockly logic editor
Inspector
In the scene settings, in the inspector, you can set the position of the object along three axes: X, Y and Z
You can learn more about the 3D editor’s interface in the article Getting to know the interface
Blockly
Actions
- Set position X: Y: Z: - instantly moves the specified object to the position set using coordinates in world space Move by coordinates
- Move instantly to the center of the object N - instantly moves the specified object by the coordinates of the second object
- Move in the direction of the X/Y/Z axis at N m/s - starts the process of moving the specified object in the direction of the selected axis with the specified speed
- Move in the direction of the X/Y/Z axis at a distance of N m with a speed of M m/s - starts the process of moving the specified object in the direction of the selected axis for the specified distance with the specified speed
- Move in the direction of the X/Y/Z axis for N s at a speed of M m/s - starts the process of moving the specified object in the direction of the selected axis for the specified time at the specified speed
- Move to object N with speed M m/s - starts the process of moving the specified object in the direction of the second object with the specified speed
- Move to X: Y: Z: coordinates at a speed of N m/s - starts the process of moving the specified object in the direction of the specified coordinates at the specified speed. The movement continues until the object reaches the coordinates
- Moves along the route List with speed N - starts the process of moving the specified object along the route with the specified speed. A route is a list of objects or coordinates in the world space, defined by vectors Move along the route
The movement continues until it is stopped by the end of movement block To change the direction of the movement, use a negative velocity value
- Close/stop/continue any movement - blocks controlling object movement:
- End - block parameter, which completes any object movement
- Suspend - block parameter, which stops object movement
- Continue - block parameter that resumes object movement, which was paused by the Pause block
Variables
- Object is moving at the moment - returns “true” if the specified object is moving at the moment. Otherwise, it returns “false”.
- Set Object minimum stopping distance in front of the target object N m. - sets the minimum distance between the set and target objects so that the movement to it is considered complete. It calculates the distance between the centers of the objects, so using a value of 0 is not recommended
- Set Object face when moving = X: Y: Z: - sets the side the object will face when moving
Value for setting the object to move “face forward”: (x: 0; y: 0; z: 1)
- Get from Object position along axis X/Y/Z - returns the position of the specified object along the selected axis in world coordinates
- Get from Object position - returns the position of the specified object in world coordinates as a vector [X; Y; Z].
- Execute Object distance - returns the straight line distance from the specified object to the second object
- Execute Object distance to object - returns straight line distance from specified object to world coordinates, specified using vector
The distance is returned in meters as a real number
Events
- Completed any move for Object - event is triggered when specified object completes any move
The movement is considered completed if the object has reached the target position, or if the movement has been stopped by the corresponding block
- Completed move to target object for Object - the event is triggered when the specified object completes move to the target object
- Completed movement to target coordinates for Object - event is triggered when specified object completes movement to target coordinates
- Reached a waypoint for Object - event is triggered when the specified object moving along the route reaches the next waypoint
Examples of use
Move by coordinates
Move by coordinates - the function allows you to move an object by specifying for it the necessary global coordinates in the scene space. Detailed information about the position of objects in the scene and their coordinates
Specifying coordinates in the Blockly editor is equivalent to specifying them in the scene editor in the inspector in the object parameter “Position”
Moving along the route
Moving along the route is the creation of a list of objects, which will be the points of the created route for your object
to create a route you usually use the standard point object, because it is not visible in playback mode
Obtaining object data
Let’s look at an example of how some of the blocks in section “Variables” work
To implement the example, we will use a chain whose update is performed all the time. Let’s put a logical condition inside it, which will be executed if the cube is stationary. If the cube is static, then the values of three parameters will be passed to the “Text” object:
- Returns object coordinates along the X axis
- Return coordinates of an object on all three axes X, Y, Z
- Return the distance from one object to another, in our case it is a cube and a player