Prototyping a Robotic Factory Game in Unity3D

I was playing Overcooked on the Nintendo Switch and wondered how quickly and easily the core functionality can be implemented in Unity.  I got the prototype working using the Nav Mesh Agent with Colliders and Trigger Events.  I played around with the implementation and while I was tempted to do another Cooking Dash equivalent, the same system can be applied for a robotic factory with a supply, process and deliver actions in a dynamic work area supporting multiple machines and potentially a virtual training platform for creating Machine Learning models for the robot controllers.

My implementation used C# interfaces for handling the interaction between the Drone Factory Robot and the Action Areas for Supply, Processing and Delivery.  The implementation on the action areas operates on the cargo object attached to the drone.

interface IDroneAction
{
    void Action(CargoArea cargoArea);
}

The following code snippet is part of the “Supply” controller action that puts an item on the Drone’s cargo hold.  The Drone controller invokes the Action(), passing the cargo controller object when it has stopped is within the action area.

public class SupplyControl : MonoBehaviour, IDroneAction
{
    public GameObject CargoPrefab;

    public void Action(CargoArea cargoArea)
    {
        if (cargoArea.IsCargoSpaceAvailable())
        {
            var item = Instantiate(CargoPrefab);
            cargoArea.AddCargo(item);
        }
    }
}

The Drone GameObject holds the DroneControl script managing movement and interactions, the CargoArea script managing cargo and the NavMeshAgent (along with the usual pieces, rigidbody, collider etc.)

Factory1

On the DroneControl script, it invokes the Action() interface if it is stopped within the action area and has not executed the action method.

if ((navMeshAgent.pathStatus == NavMeshPathStatus.PathComplete) && (navMeshAgent.remainingDistance  0)
{
    if (cargoArea.IsCargoSpaceAvailable())
    {
        var item = processedList[0];
        processedList.RemoveAt(0);
        cargoArea.AddCargo(item);
    }
    else
    {
        break;
    }
}

if (processedList.Count == 0)
{
    CurrentState = ProcessState.Waiting;
}

This setup creates a basic interaction and movement model for time management and coordination, it might even be useful for virtual factory simulation with the drones creating the objects based on received instructions.

Here’s an online WebGL deployment of the sample.

RoboticFactory WebGL

For questions, comments or contact – follow/message me on Twitter @rlozada