Object package "Sockets"
Sockets are a mechanism for connecting two or more objects into a single design. A socket includes two objects:
- Socket (point for connection)
- Plug (point to be connected)
Socket settings in the inspector
Socket
- Can be connected - parameter responsible for the possibility to connect points
- Key - a keyword that must be the same on two points to be connected
Plug
- Can be disconnected - the parameter responsible for the ability to separate sockets after connection
- Can be connected - the parameter responsible for the ability to connect points
- Key - a keyword that must be the same on two points to be connected
The size of the point determines the area of interaction with the point. Rotation regulates the connection of objects - after connection the axes of these points will coincide
Blockly
Socket
Actions | |
---|---|
Displays a prototype of the pluggable object with a plug | |
Disconnects the connected plug from the power outlet | |
Logic | |
Can connect - returns "true" if the connectivity flag is set | |
Connected - returns "true" if the point is connected to another point | |
Variables | |
Set can be connected - sets this parameter to true | |
Events | |
The event is called when a connection is made. The Point argument contains the object whose point was connected | |
The event is called when a disconnection occurs. The Point argument contains the object whose point was disconnected |
Plug
Actions | |
---|---|
Connect the plug to the object N with the socket outlet | |
Connect a plug to an object N with a socket in time M s. During this time, the object moves towards the target object and is plugged in | |
Disconnects the connected plug from the power outlet | |
Logic | |
Can be disconnected - returns "true" if the disconnectability flag is set | |
Can connect - returns "true" if the connectivity flag is set | |
Connected - returns "true" if the point is connected to another point | |
Variables | |
Set can be disconnected - sets this parameter to true | |
Set can be connected - sets this parameter to true | |
Events | |
The event is called when a connection is made. The Point argument contains the object whose point was connected | |
The event is called when a disconnection occurs. The Point argument contains the object whose point was disconnected |
Usage
- To use the mechanism to connect two objects, you need to place the socket and plug in a hierarchy to the objects you want to connect. Let's take a cube and a pyramid as an example
- Check the plug and socket:
- Can be connected checkboxes are enabled
- Same Connection Key
- Enable the parent objects (cube and pyramid) to be picked up in the hand
- Save the scene, go to view mode and hold one of the objects in your hand. Bring it to the second object, you will see a green glow around the objects. This means that the objects can be connected to each other
- While the objects are green, release the object from your hand, they will connect
More objects can be constructed in this way