Highroad Engine v1.3
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MoreMountains.HighroadEngine.VehicleAI Class Reference

Manages the driving with a simple AI : the AI follows each AIWaypoint in their order. More...

Inheritance diagram for MoreMountains.HighroadEngine.VehicleAI:

Public Member Functions

virtual void Start ()
 Initialization More...
 
virtual void LateUpdate ()
 At LateUpdate, we apply ou AI logic More...
 
virtual void OnDrawGizmos ()
 On DrawGizmos, we draw a line between the vehicle and its target More...
 

Public Attributes

bool Active
 If Active, AI controls the vehicle. More...
 
float TimeBeforeStuck = 5f
 The time in seconds before the car is reset to the last checkpoint it's met. If the value is zero, the car will remain where it is. More...
 
int MinimalDistanceToNextWaypoint = 10
 when this distance is reached, AI goes to next waypoint More...
 
float FullThrottle = 1f
 the maximum Gas Pedal Amount More...
 
float SmallThrottle = 0.3f
 the minimum Gas Pedal Amount More...
 
bool OverrideSteringSpeed = false
 
int SteeringSpeed = 300
 

Protected Member Functions

virtual void ResetAIWaypointToClosest ()
 Reset next AI waypoint to closest More...
 
virtual bool IsStuck ()
 If car stays in the same place for too long, we respawn to the last checkpoint More...
 
virtual void EvaluateNextWaypoint ()
 we determine if the current waypoint is still correct More...
 
virtual void EvaluateDirection ()
 Determine direction towards the waypoint More...
 
virtual void CalculateValues ()
 Applies controls to move vehicle towards the waypoint More...
 
virtual float PlaneDistanceToWaypoints ()
 Returns the Plane distance between the next waypoint and the vehicle More...
 

Protected Attributes

List< Vector3 > _AIWaypoints
 
BaseController _controller
 
int _currentWaypoint
 
float _direction = 0f
 
float _acceleration = 0f
 
Vector3 _targetWaypoint
 
RaceManager _raceManager
 
SolidController _solidController
 
float _targetAngleAbsolute
 
int _newDirection
 
float _stuckTime = 0f
 
Vector3 _lastPosition
 

Static Protected Attributes

const float _largeAngleDistance = 90f
 
const float _smallAngleDistance = 5f
 
const float _minimalSpeedForBrakes = 0.5f
 
const float _maximalDistanceStuck = 0.5f
 

Detailed Description

Manages the driving with a simple AI : the AI follows each AIWaypoint in their order.

This engine is generic and can be used on different types of vehicles as long as they implement BaseController with Steer and GasPedal.

Member Function Documentation

◆ CalculateValues()

virtual void MoreMountains.HighroadEngine.VehicleAI.CalculateValues ( )
protectedvirtual

Applies controls to move vehicle towards the waypoint

◆ EvaluateDirection()

virtual void MoreMountains.HighroadEngine.VehicleAI.EvaluateDirection ( )
protectedvirtual

Determine direction towards the waypoint

◆ EvaluateNextWaypoint()

virtual void MoreMountains.HighroadEngine.VehicleAI.EvaluateNextWaypoint ( )
protectedvirtual

we determine if the current waypoint is still correct

◆ IsStuck()

virtual bool MoreMountains.HighroadEngine.VehicleAI.IsStuck ( )
protectedvirtual

If car stays in the same place for too long, we respawn to the last checkpoint

◆ LateUpdate()

virtual void MoreMountains.HighroadEngine.VehicleAI.LateUpdate ( )
virtual

At LateUpdate, we apply ou AI logic

◆ OnDrawGizmos()

virtual void MoreMountains.HighroadEngine.VehicleAI.OnDrawGizmos ( )
virtual

On DrawGizmos, we draw a line between the vehicle and its target

◆ PlaneDistanceToWaypoints()

virtual float MoreMountains.HighroadEngine.VehicleAI.PlaneDistanceToWaypoints ( )
protectedvirtual

Returns the Plane distance between the next waypoint and the vehicle

Returns
The distance to the next waypoint.

◆ ResetAIWaypointToClosest()

virtual void MoreMountains.HighroadEngine.VehicleAI.ResetAIWaypointToClosest ( )
protectedvirtual

Reset next AI waypoint to closest

◆ Start()

virtual void MoreMountains.HighroadEngine.VehicleAI.Start ( )
virtual

Initialization

Member Data Documentation

◆ _acceleration

float MoreMountains.HighroadEngine.VehicleAI._acceleration = 0f
protected

◆ _AIWaypoints

List<Vector3> MoreMountains.HighroadEngine.VehicleAI._AIWaypoints
protected

◆ _controller

BaseController MoreMountains.HighroadEngine.VehicleAI._controller
protected

◆ _currentWaypoint

int MoreMountains.HighroadEngine.VehicleAI._currentWaypoint
protected

◆ _direction

float MoreMountains.HighroadEngine.VehicleAI._direction = 0f
protected

◆ _largeAngleDistance

const float MoreMountains.HighroadEngine.VehicleAI._largeAngleDistance = 90f
staticprotected

◆ _lastPosition

Vector3 MoreMountains.HighroadEngine.VehicleAI._lastPosition
protected

◆ _maximalDistanceStuck

const float MoreMountains.HighroadEngine.VehicleAI._maximalDistanceStuck = 0.5f
staticprotected

◆ _minimalSpeedForBrakes

const float MoreMountains.HighroadEngine.VehicleAI._minimalSpeedForBrakes = 0.5f
staticprotected

◆ _newDirection

int MoreMountains.HighroadEngine.VehicleAI._newDirection
protected

◆ _raceManager

RaceManager MoreMountains.HighroadEngine.VehicleAI._raceManager
protected

◆ _smallAngleDistance

const float MoreMountains.HighroadEngine.VehicleAI._smallAngleDistance = 5f
staticprotected

◆ _solidController

SolidController MoreMountains.HighroadEngine.VehicleAI._solidController
protected

◆ _stuckTime

float MoreMountains.HighroadEngine.VehicleAI._stuckTime = 0f
protected

◆ _targetAngleAbsolute

float MoreMountains.HighroadEngine.VehicleAI._targetAngleAbsolute
protected

◆ _targetWaypoint

Vector3 MoreMountains.HighroadEngine.VehicleAI._targetWaypoint
protected

◆ Active

bool MoreMountains.HighroadEngine.VehicleAI.Active

If Active, AI controls the vehicle.

◆ FullThrottle

float MoreMountains.HighroadEngine.VehicleAI.FullThrottle = 1f

the maximum Gas Pedal Amount

◆ MinimalDistanceToNextWaypoint

int MoreMountains.HighroadEngine.VehicleAI.MinimalDistanceToNextWaypoint = 10

when this distance is reached, AI goes to next waypoint

◆ OverrideSteringSpeed

bool MoreMountains.HighroadEngine.VehicleAI.OverrideSteringSpeed = false

◆ SmallThrottle

float MoreMountains.HighroadEngine.VehicleAI.SmallThrottle = 0.3f

the minimum Gas Pedal Amount

◆ SteeringSpeed

int MoreMountains.HighroadEngine.VehicleAI.SteeringSpeed = 300

◆ TimeBeforeStuck

float MoreMountains.HighroadEngine.VehicleAI.TimeBeforeStuck = 5f

The time in seconds before the car is reset to the last checkpoint it's met. If the value is zero, the car will remain where it is.


The documentation for this class was generated from the following file: