Highroad Engine v1.3
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
MoreMountains.HighroadEngine.SolidController Class Reference

Solid Controller class, that handles vehicles with suspension This allows for a more dynamic behaviour of the vehicles and allows for bumpy roads, slopes or even loops This controller also offers easier extendability thanks to the SolidBehaviourExtender. If you want to create a vehicle using this controller, you'll need to setup its suspension correctly, and pay attention to the weight repartition. For that, you can simply duplicate one of the demo vehicles, or have a look at the documentation that explains how to setup a vehicle, step by step. More...

Inheritance diagram for MoreMountains.HighroadEngine.SolidController:
MoreMountains.HighroadEngine.BaseController MoreMountains.HighroadEngine.IActorInput

Public Types

enum  Gears { forward , reverse }
 Gears enum. Car can be forward driving or backward driving (reverse) More...
 

Public Member Functions

override void Respawn ()
 Resets the position of the vehicle. More...
 
- Public Member Functions inherited from MoreMountains.HighroadEngine.BaseController
virtual bool HasJustFinished (int finalRankPosition)
 Gets a value indicating whether this vehicle has just finished the race. This property will return true only once. More...
 
virtual void MainActionPressed ()
 Button Main Action is being pressed More...
 
virtual void MainActionDown ()
 Button Main Action is pressed down More...
 
virtual void MainActionReleased ()
 Button Main Action is released More...
 
virtual void AltActionPressed ()
 Button Alt Action is being pressed More...
 
virtual void AltActionDown ()
 Button Alt Action is pressed down More...
 
virtual void AltActionReleased ()
 Button Alt Action is released More...
 
virtual void RespawnActionPressed ()
 Button Respawn Action is being pressed More...
 
virtual void RespawnActionDown ()
 Button Respawn Action is pressed down More...
 
virtual void RespawnActionReleased ()
 Button Respawn Action is released More...
 
virtual void LeftPressed ()
 Button Left is being pressed More...
 
virtual void RightPressed ()
 Button Right is being pressed More...
 
virtual void UpPressed ()
 Button Up is being pressed More...
 
virtual void DownPressed ()
 Button Down is being pressed More...
 
virtual void MobileJoystickPosition (Vector2 value)
 Update of the mobile joystick position More...
 
virtual void HorizontalPosition (float value)
 Update of the horizontal value (from -1 to 1) More...
 
virtual void VerticalPosition (float value)
 Update of the vertical value (from -1 to 1) More...
 
virtual void LeftReleased ()
 Button Left is released More...
 
virtual void RightReleased ()
 Button Right is released More...
 
virtual void UpReleased ()
 Button Up is released More...
 
virtual void DownReleased ()
 Button Down is released More...
 
virtual void OnTriggerEnter (Collider other)
 Describes what happens when the object starts colliding with something Used for checkpoint interaction More...
 
virtual void OnTriggerStay (Collider other)
 Describes what happens when something is colliding with our object Used to apply a boost force to the vehicle while staying in a boost zone. More...
 
virtual void OnTriggerExit (Collider other)
 Describes what happens when the collision ends Removes "boost" state when the vehicle exits a boost zone More...
 
virtual void EnableControls (int controllerId)
 Enables the controls. More...
 
virtual void DisableControls ()
 Disables the controls. More...
 

Public Attributes

float EngineForce = 1000
 The engine's power. More...
 
Vector3 CenterOfMass = new Vector3(0, -1, 0)
 Point of gravity of the car is set below. This helps the Unity Physics with car stability. More...
 
float GroundDistance = 1f
 The distance to the ground at which we consider the car is grounded. More...
 
float OffroadPenaltyFactor = 2f
 the penalty applied when going offroad More...
 
float CarGrip = 10f
 the wheel's grip force. The higher the value, the less the car will slide when turning More...
 
float FullThrottleVelocity = 30
 The speed above which the vehicle is considered as going full throttle. The vehicle's speed can be higher than that. More...
 
float MinimalTurningSpeed = 1f
 The minimum required speed for the vehicle to turn. More...
 
float ForwardForceHeight = 1f
 The height at which forward force will be applied. More...
 
AnimationCurve TorqueCurve
 Additional torque force based on speed. More...
 
AnimationCurve BackwardForceCurve
 Rotation force when going backward. More...
 
float GripSpeedFactor = 0.02f
 Grip factor multiplier. The higher that value, the more this vehicle will stick to the road, even at high speeds. More...
 
int MaxGripValue = 100
 The vehicle's maximum grip value. More...
 
float RadiusWheel = 0.5f
 The size of the wheel. More...
 
float SpringConstant = 20000f
 Spring. More...
 
float DamperConstant = 2000f
 Damper. More...
 
float RestLength = 0.5f
 The length of the suspension spring when resting. More...
 
float SpringTorqueForce = 1000f
 The horizontal rotation force that will angle the car left or right to simulate spring compression when turning. More...
 
UnityAction< Collision > OnCollisionEnterWithOther
 An event triggered when the vehicle collides with something. More...
 
UnityAction OnRespawn
 An event triggered when the vehicle is respawned. More...
 
- Public Attributes inherited from MoreMountains.HighroadEngine.BaseController
float BoostForce = 1f
 the force applied when the vehicle is in a boost zone More...
 
float RigidBodyDragInLoop = 1f
 The temporary value of rigidbody.drag when the vehicle is inside a loop zone. This allows for better movement inside the loop. More...
 
float SteeringSpeed = 100f
 the speed at which the car steers More...
 
bool AutoForward = false
 Set this to true if you want the vehicle to accelerate forever. More...
 

Protected Member Functions

override void Awake ()
 Physics initialization More...
 
override void Start ()
 Unity start function More...
 
virtual void Update ()
 Update main function More...
 
virtual void UpdateGroundSituation ()
 Updates the ground situation for this car. More...
 
virtual void FixedUpdate ()
 Fixed update. We apply physics and input evaluation. More...
 
virtual void UpdateEngineForceValue ()
 Computes the engine's power. This value can be used by a wheel to apply force if conditions are met More...
 
virtual void UpdateTorqueRotation ()
 Applies a torque force to the vehicle when the user wants to turn More...
 
virtual void UpdateSlideForce ()
 Applies slide force to the vehicle More...
 
virtual void UpdateAirRotation ()
 Handles rotation of the vehicle in the air More...
 
virtual void OnCollisionEnter (Collision other)
 Raises the collision enter event. More...
 
virtual void OnDrawGizmos ()
 Draws debug info More...
 

Protected Attributes

float _springForce = 0f
 
float _damperForce = 0f
 
RaycastHit _hit
 
Vector3 _startPosition
 
Quaternion _startRotation
 
GameObject _groundGameObject
 
LayerMask _noLayerMask = ~0
 
- Protected Attributes inherited from MoreMountains.HighroadEngine.BaseController
Rigidbody _rigidbody
 
Collider _collider
 
RaceManager _raceManager
 
Transform[] _checkpoints
 
int _currentWaypoint = 0
 
int _lastWaypointCrossed = -1
 
float _defaultDrag
 
int _controllerId = -1
 
int _finisherPosition = 0
 αΊ€hen > 0, vehicle has finished the race. This is it final rank. More...
 
float _currentGasPedalAmount
 

Properties

Gears CurrentGear [getprotected set]
 The current gear value. More...
 
Vector3 CurrentEngineForceValue [getprotected set]
 Current engine force value used by wheels. More...
 
virtual bool IsOffRoad [get]
 Gets a value indicating whether this car is offroad. More...
 
virtual float NormalizedSpeed [get]
 Gets the normalized speed. More...
 
virtual bool Forward [get]
 Returns true if vehicle is going forward More...
 
virtual bool Braking [get]
 Returns true if vehicle is braking More...
 
virtual float HorizontalAngle [get]
 Returns the current angle of the car to the horizon. Used, for example, to disable AI's direction when the vehicle goes over a certain angle. allows for easier loop handling More...
 
virtual float ForwardNormalizedSpeed [get]
 Gets the forward normalized speed. Used to evaluate the engine's power More...
 
virtual float SlideSpeed [getprotected set]
 The current lateral speed value of the vehicle. More...
 
- Properties inherited from MoreMountains.HighroadEngine.BaseController
int CurrentLap [getprotected set]
 Returns the current lap. More...
 
float CurrentSteeringAmount [getset]
 Gets or sets the current steering amount from -1 (full left) to 1 (full right). 0 when none. More...
 
float? CurrentGasPedalAmount [getset]
 Gets or sets the current gas pedal amount. 1 for full acceleration. -1 for full brake or reverse. 0 for nothing. More...
 
virtual bool IsPlaying [getprotected set]
 Gets or sets a value indicating whether this user is playing. More...
 
virtual bool IsGrounded [getprotected set]
 Gets or sets a value indicating whether this instance is grounded. More...
 
virtual bool IsOnSpeedBoost [getprotected set]
 Gets or sets a value indicating whether this instance is on speed boost. More...
 
virtual float Speed [get]
 Gets the vehicle speed. More...
 
virtual int Score [get]
 Gets the player score. More...
 
virtual float DistanceToNextWaypoint [get]
 Gets the distance to the next waypoint. More...
 
int FinalRank [get]
 Gets the final rank. 0 if vehicle has not ended. More...
 

Additional Inherited Members

- Protected Types inherited from MoreMountains.HighroadEngine.BaseController
enum  Zones { SpeedBoost , JumpBoost , LoopZone }
 

Detailed Description

Solid Controller class, that handles vehicles with suspension This allows for a more dynamic behaviour of the vehicles and allows for bumpy roads, slopes or even loops This controller also offers easier extendability thanks to the SolidBehaviourExtender. If you want to create a vehicle using this controller, you'll need to setup its suspension correctly, and pay attention to the weight repartition. For that, you can simply duplicate one of the demo vehicles, or have a look at the documentation that explains how to setup a vehicle, step by step.

Member Enumeration Documentation

◆ Gears

Gears enum. Car can be forward driving or backward driving (reverse)

Enumerator
forward 
reverse 

Member Function Documentation

◆ Awake()

override void MoreMountains.HighroadEngine.SolidController.Awake ( )
protectedvirtual

Physics initialization

Reimplemented from MoreMountains.HighroadEngine.BaseController.

◆ FixedUpdate()

virtual void MoreMountains.HighroadEngine.SolidController.FixedUpdate ( )
protectedvirtual

Fixed update. We apply physics and input evaluation.

◆ OnCollisionEnter()

virtual void MoreMountains.HighroadEngine.SolidController.OnCollisionEnter ( Collision  other)
protectedvirtual

Raises the collision enter event.

Parameters
otherOther object.

◆ OnDrawGizmos()

virtual void MoreMountains.HighroadEngine.SolidController.OnDrawGizmos ( )
protectedvirtual

Draws debug info

◆ Respawn()

override void MoreMountains.HighroadEngine.SolidController.Respawn ( )
virtual

Resets the position of the vehicle.

Reimplemented from MoreMountains.HighroadEngine.BaseController.

◆ Start()

override void MoreMountains.HighroadEngine.SolidController.Start ( )
protectedvirtual

Unity start function

Reimplemented from MoreMountains.HighroadEngine.BaseController.

◆ Update()

virtual void MoreMountains.HighroadEngine.SolidController.Update ( )
protectedvirtual

Update main function

◆ UpdateAirRotation()

virtual void MoreMountains.HighroadEngine.SolidController.UpdateAirRotation ( )
protectedvirtual

Handles rotation of the vehicle in the air

◆ UpdateEngineForceValue()

virtual void MoreMountains.HighroadEngine.SolidController.UpdateEngineForceValue ( )
protectedvirtual

Computes the engine's power. This value can be used by a wheel to apply force if conditions are met

◆ UpdateGroundSituation()

virtual void MoreMountains.HighroadEngine.SolidController.UpdateGroundSituation ( )
protectedvirtual

Updates the ground situation for this car.

◆ UpdateSlideForce()

virtual void MoreMountains.HighroadEngine.SolidController.UpdateSlideForce ( )
protectedvirtual

Applies slide force to the vehicle

◆ UpdateTorqueRotation()

virtual void MoreMountains.HighroadEngine.SolidController.UpdateTorqueRotation ( )
protectedvirtual

Applies a torque force to the vehicle when the user wants to turn

Member Data Documentation

◆ _damperForce

float MoreMountains.HighroadEngine.SolidController._damperForce = 0f
protected

◆ _groundGameObject

GameObject MoreMountains.HighroadEngine.SolidController._groundGameObject
protected

◆ _hit

RaycastHit MoreMountains.HighroadEngine.SolidController._hit
protected

◆ _noLayerMask

LayerMask MoreMountains.HighroadEngine.SolidController._noLayerMask = ~0
protected

◆ _springForce

float MoreMountains.HighroadEngine.SolidController._springForce = 0f
protected

◆ _startPosition

Vector3 MoreMountains.HighroadEngine.SolidController._startPosition
protected

◆ _startRotation

Quaternion MoreMountains.HighroadEngine.SolidController._startRotation
protected

◆ BackwardForceCurve

AnimationCurve MoreMountains.HighroadEngine.SolidController.BackwardForceCurve

Rotation force when going backward.

◆ CarGrip

float MoreMountains.HighroadEngine.SolidController.CarGrip = 10f

the wheel's grip force. The higher the value, the less the car will slide when turning

◆ CenterOfMass

Vector3 MoreMountains.HighroadEngine.SolidController.CenterOfMass = new Vector3(0, -1, 0)

Point of gravity of the car is set below. This helps the Unity Physics with car stability.

◆ DamperConstant

float MoreMountains.HighroadEngine.SolidController.DamperConstant = 2000f

Damper.

◆ EngineForce

float MoreMountains.HighroadEngine.SolidController.EngineForce = 1000

The engine's power.

◆ ForwardForceHeight

float MoreMountains.HighroadEngine.SolidController.ForwardForceHeight = 1f

The height at which forward force will be applied.

◆ FullThrottleVelocity

float MoreMountains.HighroadEngine.SolidController.FullThrottleVelocity = 30

The speed above which the vehicle is considered as going full throttle. The vehicle's speed can be higher than that.

◆ GripSpeedFactor

float MoreMountains.HighroadEngine.SolidController.GripSpeedFactor = 0.02f

Grip factor multiplier. The higher that value, the more this vehicle will stick to the road, even at high speeds.

◆ GroundDistance

float MoreMountains.HighroadEngine.SolidController.GroundDistance = 1f

The distance to the ground at which we consider the car is grounded.

◆ MaxGripValue

int MoreMountains.HighroadEngine.SolidController.MaxGripValue = 100

The vehicle's maximum grip value.

◆ MinimalTurningSpeed

float MoreMountains.HighroadEngine.SolidController.MinimalTurningSpeed = 1f

The minimum required speed for the vehicle to turn.

◆ OffroadPenaltyFactor

float MoreMountains.HighroadEngine.SolidController.OffroadPenaltyFactor = 2f

the penalty applied when going offroad

◆ OnCollisionEnterWithOther

UnityAction<Collision> MoreMountains.HighroadEngine.SolidController.OnCollisionEnterWithOther

An event triggered when the vehicle collides with something.

◆ OnRespawn

UnityAction MoreMountains.HighroadEngine.SolidController.OnRespawn

An event triggered when the vehicle is respawned.

◆ RadiusWheel

float MoreMountains.HighroadEngine.SolidController.RadiusWheel = 0.5f

The size of the wheel.

◆ RestLength

float MoreMountains.HighroadEngine.SolidController.RestLength = 0.5f

The length of the suspension spring when resting.

◆ SpringConstant

float MoreMountains.HighroadEngine.SolidController.SpringConstant = 20000f

Spring.

◆ SpringTorqueForce

float MoreMountains.HighroadEngine.SolidController.SpringTorqueForce = 1000f

The horizontal rotation force that will angle the car left or right to simulate spring compression when turning.

◆ TorqueCurve

AnimationCurve MoreMountains.HighroadEngine.SolidController.TorqueCurve

Additional torque force based on speed.

Property Documentation

◆ Braking

virtual bool MoreMountains.HighroadEngine.SolidController.Braking
get

Returns true if vehicle is braking

true if braking; otherwise, false.

◆ CurrentEngineForceValue

Vector3 MoreMountains.HighroadEngine.SolidController.CurrentEngineForceValue
getprotected set

Current engine force value used by wheels.

◆ CurrentGear

Gears MoreMountains.HighroadEngine.SolidController.CurrentGear
getprotected set

The current gear value.

◆ Forward

virtual bool MoreMountains.HighroadEngine.SolidController.Forward
get

Returns true if vehicle is going forward

true if forward; otherwise, false.

◆ ForwardNormalizedSpeed

virtual float MoreMountains.HighroadEngine.SolidController.ForwardNormalizedSpeed
get

Gets the forward normalized speed. Used to evaluate the engine's power

The forward normalized speed.

◆ HorizontalAngle

virtual float MoreMountains.HighroadEngine.SolidController.HorizontalAngle
get

Returns the current angle of the car to the horizon. Used, for example, to disable AI's direction when the vehicle goes over a certain angle. allows for easier loop handling

The horizontal angle.

◆ IsOffRoad

virtual bool MoreMountains.HighroadEngine.SolidController.IsOffRoad
get

Gets a value indicating whether this car is offroad.

◆ NormalizedSpeed

virtual float MoreMountains.HighroadEngine.SolidController.NormalizedSpeed
get

Gets the normalized speed.

The normalized speed.

◆ SlideSpeed

virtual float MoreMountains.HighroadEngine.SolidController.SlideSpeed
getprotected set

The current lateral speed value of the vehicle.


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