🎨
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
  • PID Controller
  • Max Rotation Angles
  • Creating Your Own Spaceship Behaviours

Was this helpful?

  1. AI - Space Combat Kit

AI Spaceship Behaviours

The AI Spaceship Behaviour class provides a base class for creating spaceship AI behaviours, and is used for the following behaviour components:

  • Obstacle Avoidance Behaviour

  • Spaceship Combat Behaviour

  • Spaceship Attack Behaviour

  • Spaceship Evade Behaviour

  • Spaceship Patrol Behaviour

  • Spaceship Formation Behaviour

  • Spaceship Move To Position Behaviour

The main features of this base class are the PID controller and max rotation angles settings, which enable you to control the way the spaceship maneuvers during each behaviour.

PID Controller

The PID (Proportional - Integral - Derivative) controller is a type of controller used in robotics and control systems to enable an object to steer or move toward something by minimizing something known as the 'error value'.

It's not necessary to know about PID controllers to get everything you need out of the AI, and in most cases, leaving it at the default values will work for any use case.

The Error Value

In very simple terms, the error values that the controller seeks to minimize are:

  • For steering, the difference in angle between the vehicle's current direction versus the direction you want it to be facing

  • For movement, the distance between where the vehicle currently is versus where you want it to be

Proportional/Integral/Derivative

  • The Proportional value is how much the vehicle steers/moves as a result of the difference between the current direction/position compared to the desired direction/position

  • The Integral value is how much the controller output accumulates as a result of the difference not being reduced fast enough

  • The Derivative value is a 'braking' value that provides an opposing pressure as the error value approaches zero - to minimize swinging around the target value

Max Rotation Angles

You may want spaceships to limit the amount that they rotate on a specific axis while maneuvering, for example space fighters might roll hard while capital ships simply turn sideways.

You can customize the maximum rotation values around each axis (local X, Y and Z axes) by setting the Max Rotation Angles field in the inspector of any AI Spaceship Behaviour component.

  • X-value is pitch (nose up/down)

  • Y-value is yaw (nose left/right, in most cases leave this at 360)

  • Z-value is roll

Creating Your Own Spaceship Behaviours

To create your own spaceship behaviour:

  1. Create a new script that extends the AI Spaceship Behaviour base class.

  2. Override the Behaviour Update function to add your own code.

  3. In your own code, call the Steer Toward and Move Toward functions and pass the target position to make the ship steer and move toward it.

For example:

public class MySpaceshipBehaviour : AISpaceshipBehaviour
{
    public override bool BehaviourUpdate
    {
        if (!base.BehaviourUpdate()) return false;
        
        SteerToward(somePosition);
        MoveToward(somePosition);
    }
}

PreviousAI SetupNextAI - Mech Combat Kit

Last updated 2 years ago

Was this helpful?