In this short tutorial we are creating a small demo model with a source, a conveyor and a light barrier.
The needed 3D components are already available. If you would like to use own 3D data, you would need to import the 3D data from your CAD system using the PIXYZ Plugin for Unity or another suitable solution. Please see more about importing your own 3D Data with PIXYZ in section Import 3D data
You should always create your models outside the game4automation folder. This is because if you import a new Version of Game4Automation, you would not like to destroy what you did. If you keep your scripts outside the game4automation folder this will enable you to update your model with new releases of Game4Automation without problems.
First create a new folder. We will call this folder my_game4automation. Select assets and right click Create > Folder. Select the folder, hit F2 and name it to my_game4automation.
For creating a new scene right click on the newly created folder my_game4automation and select Create > Scene. Alternatively you could use Assets > Create > Scene in the main menu. Select the created scene and rename it (with F2) for example to Tutorial:
You should now have a Folder my_game4automation with an included scene Tutorial. This should look like this:
If you click on the scene it is still empty. We now insert the standard Game4Automation controller, lights and a base plate. This is a prepared asset. We can insert it with the Main menu game4automation > Add component > game4automation. Or we can drag alternatively the game4automation asset (under Assets > game4automation > game4automation) into the scene.
Now your model should look like this:
Because in the Gam4Automation object lights are already included, you could delete the standard directional light.
Next we insert a 3D component. For the tutorial we use a prepared one, which is already used by the demo model. Select the conveyor under Assets > game4automation > 3DPfefabs > ConveyorSmall and drag it into the scene. Place it somewhere in the middle of the base plate.
You can move the conveyor with the gizmo, which is visible as long as the conveyor is selected. Or you put in 0,0,0 into the Transform Position property. This will place the zero point of the conveyor onto the world zero point (which should be also the middle of the base plate):
This step is optional. The conveyor prefab is already equipped with some Game4Automation components. But we would like to show you in this tutorial the full workflow. Like it would be without anything prepared - based on imported 3D objects.
This is why we are deleting the components and add them later on again. You could also skip this step if wished and continue with Insert a source.
Delete the component Drive on the object ConveyorSmall and also delete afterwards the Rigidboy on the object ConveyorSmall:
Next delete Transport Surface, Box Collider and Rigidboy on ConveyorSmall.Conveyor.Conveyor:
You learned how to remove scripts from objects ;-).
You now removed everything what is prepared and we will add these needed scripts again in this tutorial.
We now have an empty 3D component. No kinematic and physical behavior is attached yet. Gam4Automation prepered several components and scripts which are helping you to do that.
First we need to add a Transport Surface to the conveyor. For doing that we select the component ConveyorSmall.Conveyor.Conveyor. We select in the main menu game4automation > Add Script > Transport Surface or we drag and drop the script TransportSurface under Assets>game4automation onto ConveyorSmall.Conveyor.Conveyor.
As a result your conveyor should look like this:
We now insert a Drive on the top level of the conveyor. Basically the Drive could be anywhere in the structure of the 3D model. On our experience, it is a good practice to put it on the top level of the 3D component.
Select the ConveyorSmall component in your Scene and select in the main menu Tools>game4automation>Add Script>Drive :
Alternatively you can also drag and drop the Drive Script under Assets > game4automation > Drive onto the Inspector window of ConveyorSmall.
And as a 3rd option you could also use Add Component on the Inspector window and than type in Drive and select the filtered script to assign it to the 3D component:
Please remember. Most times you can add scripts on 3D components in 3 ways
- With the main menu
- By dragging and dropping it from the Assets folder Assets>game4automation
- Or by using Add Component in the Inspector window
To make the Drive move the transport surface please open the Drive Script and add 1 into the property Transport Surfaces > Size. You are now able to drag ConveyorSmall.Conveyor.Conveyor.TransportSurface into this property:
A source is a 3D object which contains a Source script. This Source script is during simulation / runtime copying the 3D component based on the source parameters and is initiating the new MU (Movable Unit) with parameters.
All totally free moving objects in the Gam4Automation framework are called MU
Please select Assets > game4automation > 3DPrefabs > Can and drag and drop it into the scene. Place the can at the beginning and on top of the conveyor:
Now we can test the conveyor. Start the simulation with the Unity Play button.
You can now select the ConveyorSmall and start the Drive by setting the Jog Forward property. You will see that the transport surface will start to move and the cans will start falling on the base plate at the end.
If you change properties during runtime these properties are not saved. You must change properties in edit mode to save them. This means that you can also select Jog Forward before simulation and the Drive will always start moving automatically at simulation start.
You might see that the texture on the conveyor is not moving in the righ relation and the right direction. You neet to set the texture scale yourself. Please select the transport surface and enter a -2 into property Texture Scale:
As a last step we would like to place a Sensor (light beam) at the end of the conveyor. Please drag and drop Assets > game4automation > SensorBeam onto the end of the conveyor. Start the simulation and you will see that the Sensor is getting red each time a can is entering the Sensor :
You can also use game4automation > Add Component > SensorBeam to add the Sensor .
This is just a first quick starter. Please check the Demo model and learn how the functions are realized. Also check the section Physics to learn more about the physics simulations, collision detection and kinematic movements. Based on that you should check the whole section Components & Scripts to learn more about the details.