🎨
UVC
  • Introduction
  • Installation
    • Installing in New Project
    • Installing in Existing Project - SCK
    • Installing in Existing Project - MCK
  • Space Combat Kit Tour
  • Mech Combat Kit Tour
  • Player Setup
  • Vehicle Framework
    • Game Agents
    • Vehicles
    • Modules
      • Module Mounts
      • Modules
      • Module Types
      • Module Attachments
      • Display Module On UI
      • Module Managers
  • Input
    • General Input
    • Vehicle Input
    • Rewired Integration
  • Player/AI
  • Spaceships
    • Speed UI
    • Space Fighters
    • Capital Ships
  • Mechs
    • Speed UI
  • Vehicle Control Animations
  • Character Enter/Exit
  • Camera
    • Camera Setup
    • Vehicle Setup
    • Secondary Cameras
    • Death Camera
  • Weapons
    • Framework
      • Triggerables System
      • Weapon System
    • Vehicle Setup
      • Vehicle Weapons
      • Cursor Aiming
    • Projectile Weapons
    • Beam Weapons
    • Missile Weapons
    • Resource Handling (Ammo/Heat)
    • Turrets
    • HUD Weapon Info
    • Health Modifier Volumes
  • Radar
    • Radar Setup
    • Target Setup
    • Target Selectors
    • Trackable Types
    • Improving Radar Performance
    • Target Notification
    • Radar Audio
  • Health
    • Health Framework
      • Health
      • Damageable
      • Damage Receiver
      • Health Modifier
      • Health Types
      • Health Modifier Types
      • Surface Types
    • Vehicle Setup
    • Damageable Object Setup
    • Detonators
    • Health Recharge
    • Health UI
    • Energy Shield
    • Damageable Module Linkers
  • HUD
    • HUD Basics
    • HUD Manager Setup
    • Custom HUD Components
    • HUD Module Display
    • Camera View Management
    • HUD Cursor / Reticle
    • Weapon UI
    • Resource Container UI
    • 2D Radar
    • 3D Radar
    • Target Boxes
    • Target Holograms
    • Minimaps
    • HUD Distance Lookup
  • Loadout
  • AI - Space Combat Kit
    • AI Setup
    • AI Spaceship Behaviours
  • AI - Mech Combat Kit
  • Game States
  • Teams
  • Floating Origin
  • Object Pooling
  • Menus
    • Creating Menus
    • Button Controllers
  • Rumbles
  • Rigidbody Characters [WIP]
  • Utilities [WIP]
    • Object Triggers
    • Shadow Caster Doubles
    • Gimbals
    • Game State Post Process Enabler
  • Objectives
  • Resources System
    • Resource Containers
    • Resource Handlers
    • Resource Container Triggers
    • Module/Vehicle Resource Usage
    • UI
  • Cutscenes
  • URP Upgrading
Powered by GitBook
On this page
  • Creating A Player
  • Creating An AI
  • Setting The Starting Vehicle
  • Getting The Current Vehicle
  • Entering/Exiting Vehicles During Gameplay
  • Killing/Reviving Game Agents
  • Accessing Game Agents

Was this helpful?

Player/AI

Creating A Player

To create a new Player:

  1. Create a new game object and add a Game Agent component.

  2. Go to the inspector of the Game Agent component and check the Is Player checkbox

To check if a specific game agent is the player in code, use the following:

// Check if the game agent is a player
if (someGameAgent.IsPlayer)
{
    // Yes it's a player
}

Creating An AI

To create a new AI:

  1. Create a new game object and add a Game Agent component.

  2. Go to the inspector of the Game Agent component and uncheck the 'Is Player' checkbox.

To check if a specific game agent is an AI in code, use the following:

// Check if the game agent is an AI
if (!someGameAgent.IsPlayer)
{
    // Yes it's an AI
}

Setting The Starting Vehicle

To make the Game Agent enter a vehicle when the scene starts, drag a vehicle (not a prefab, must be a vehicle in the scene) into the Starting Vehicle field in the inspector.

Getting The Current Vehicle

To get the vehicle that a Game Agent is currently in, use the following code:

// Get the vehicle that the Game Agent is in
Vehicle vehicle = someGameAgent.Vehicle;

Entering/Exiting Vehicles During Gameplay

To enter/exit a vehicle during gameplay, simply call the Game Agent's Enter Vehicle function like so:

// Enter a vehicle
myGameAgent.EnterVehicle(myVehicle);

// Exit vehicle
myGameAgent.EnterVehicle(null);

Killing/Reviving Game Agents

Game Agents are automatically killed when the vehicle they are in is destroyed.

Here are examples for how to use the relevant functions.

// Kill the game agent
myGameAgent.Kill();

// Revive the game agent
myGameAgent.Revive();

// Check if the game agent is dead
if (myGameAgent.IsDead)
{
    // Some code
}

Accessing Game Agents

To make it as easy as possible to access all the game agents in the scene, the Game Agent Manager component has been provided.

The Game Agent Manager is a singleton class, which means there must only be one in the scene at any time. Just add it to any game object anywhere in the scene.

This component does several key things:

  • Stores all the Game Agents in the scene for easy access

  • Stores a reference to the 'Focused Game Agent' which provides a single reference point to the player for things like camera following, rumble effects, etc.

  • Provides events for other systems to receive notifications when the player switches vehicles, dies, is revived, etc

All you need to do is add the component anywhere in the scene and other scripts can find it using the static 'GameAgentManager.Instance' reference:

// Get a reference to the player
GameAgent player = GameAgentManager.Instance.FocusedGameAgent;

// Get a list of all the game agents in the scene
List<GameAgent> gameAgentsInScene = GameAgentManager.Instance.GameAgents;
PreviousRewired IntegrationNextSpaceships

Last updated 5 months ago

Was this helpful?

If you have a character and you want it to be able to enter/exit a vehicle when in close proximity, see .

this section