Purpose

Spawn individual agents or squads, and then commandeer any single unit with full first-person fire/movement controls. 

How to Use

Spawn Controls: 

  • Hold left-click and move cursor to rotate camera
  • Right-click on plane to open menu to add a new agent
  • Middle-click on plane to open menu to add new squad
  • Right-click on agent to open menu to commandeer agent
  • Press Backspace to exit controlling an agent

First-Person Controls:

  • WASD keys – Move agent
  • Left-click – Fire weapon
  • Space bar – Jump
  • F key – Toggle camera positions

Scene Location & Name

Assets/Ride/Examples/DynamicUnitSpawn/DynamicSpawnExample.unity

Setup Requirements 

Utilize the dynamic spawn commands API for your scene by adding the DynamicSpawnExample script. 

DynamicSpawnExample Script

First, add this script to an object in your scene to enable spawn of agents/squad and subsequent control of units.

Point the Simple Camera parameter to the Main Camera in your scene.

Note, add the “Simple Terrain Camera” script component to your main camera for left-click cursor angle manipulation.

In the Pop Up Button Image parameter, select your Panel child object of Canvas (see below).

SoldierBlue and GOList Prefabs, Plane, EventSystem and Canvas Objects

Next, instance standard Unity objects: 3D Plane, UI EventSystem and Canvas. Currently, you’ll need to create your own context menu with Panel and Button objects to place under Canvas. See the example in-scene.

Ensure the Panel object is chosen in the Pop Up Button Image parameter of the DynamicSpawnExample script object.

Lastly, instance the RIDE GOList prefab and the SoldierBlue scene prefab to load the agent assets at run-time. Change the Size value of Scene Game Objects to 1, and add the SoldierBlue prefab in the field. Rememeer to hide (uncheck) the SoldierBlue instance by default in the scene.

Note

A future update may include a new Canvas prefab with DynamicSpawnExample_Menu ready for drag-and-drop scene placement.

Scroll Up