3. Conveyor Component - Theuntextured/AsyncConveyorPlugin GitHub Wiki
What is it?
The conveyor component can be added to any actor and it allows it to have conveyor belt functionality.
The component can therefore be added to a blueprint which is child of any other actor class. For example if your game has a "BP_BuildPieceBase" for example, you can create a "BP_Conveyor" which is child of "BP_BuildPieceBase" and then simply add the component.
Setting It Up
After adding the component to an actor, it is suggested that in the construction script of the actor you add the following piece of blueprint:
Where "Debug" is a new boolean. This will allow for the visualization of the nodes which you are to add.
In the Details panel, you can find the following section:
- Speed: the speed of the items on the belt (measured in Unreal units / second) - can be negative.
- Item spacing: The minimum spacing between items on a belt.
- Belt End Behaviour: None if items should simply stop when reaching the end of a conveyor. Drop if items should be dropped, and Auto Extract if items should be automatically extracted? (Implementation of dropping in the conveyor manager)
- Auto insert determines how and if items should be automatically inserted onto the conveyor or not.
- Lock Rotation will lock the rotation of items on it. The rotation will be kept the same as it was once it was inserted from another conveyor.
NOTE: I would suggest not dragging to set properties, but rather type them manually, since running the "Draw Debug Shapes" function can drop frames drastically if called several times a frame.
Finally, Nodes is a bit more complex:
In the image, you can see an example for a simple flat conveyor, which can then be visualized as follows:
Each item in the Nodes array represents the location of each node (blue sphere) and the indices of the connections it leads to. The index refers to the array you are currently modifying.
Adding a Conveyor Mesh
In order to add a mesh to the conveyor belt, there is no "preferred way" for this plugin. Whether you add a static mesh, skeletal mesh, or if you animate a static mesh using materials, it is up to you. Just make sure that when you set the speed of the conveyors, you also update the material or the animation.
My implementation in the showcase project is as follows:
I created a material for my moving part of the conveyor. This is nothing special and is definitely not efficient:
If using my method, remember to correctly scale UVs relative to the size of the face in world and to rotate it in the correct direction to make the conveyor material move in the correct direction.
I then added a static mesh to my conveyor actor, and in the construction script I added the following to create a dynamic material instance which I can access later on. The "Speed Mod" variable is just an extra variable which I created, which is a multiplier for the speed of the visual on the material.
Then, every time you want to modify the speed of the conveyor, update the material, as such (here I am halving its speed):
Functions & Properties
Functions
Set Speed & Set Spacing
These nodes allow you to change the speed of the conveyor during runtime after the belt has been placed.
Draw Debug Shapes
Allows you to visualize the nodes in the conveyor.
Properties
Manager
The conveyor manager it is linked to.
Splines (From version v1.3.0)
Since v1.3.0, you can use splines to indicate the path that items should follow on a conveyor.
To do this, the first step is to add one or more spline components (USplineComponent) to your conveyor belt actor, as shown below:
Once you have added the spline, you must make it start one one node, and end on a connected node, as such:
After doing such, you can reshape your conveyor as you like, just keep the first and last points in the position of the Conveyor Component's nodes (Blue spheres), which you have set previously. The spline can have as many points as you like and can be as complex as you like.
Once you are done with editing your spline, you will be able to see the items follow it! (The debug mode for the Conveyor Manager actor will also display which conveyor connections are connected to splines).
Adding a Conveyor Component During Runtime
It is completely possible to set up a conveyor component, using the "Add Conveyor Component" node.
Simply fill in the parameters as you would in the settings and you're good to go!