Table of Contents

Effects

Effects Manager

EffectsManager menu.

Controls all the vehicle effects.

Effect system makes use of VehicleComponents and therefore each Effect can be turned on or off, be enabled or disable or have LOD set.

  • All Effects with manager in the name manage multiple instances of the effect, usually one for each wheel - e.g. skidmarks or surface particles.
2023/05/14 16:35

Exhaust Flash

ExhaustFlash inspector.

ExhaustFlash Effect is used to imitate flames shooting out of exhaust. The method to achieve this is identical to the one used for most muzzle flash in FPS games; that is a set of images gets enabled and disabled at rapid rate with different sprite and scale each time. This is a performant way to achieve the effect while avoiding particle effects.

Setup

Adding Quads
  • Create and place two Quads perpendicular to each other. Move them to the location of the exhaust.
  • Remove any colliders from Quads.
  • Create a new material that uses Particles/Standard Unlit (Unity 2019) or equivalent shader with Transparent rendering and Multiply color mode. The included example on Sports Car prefab can be copied. Assigning one of the included flame textures will show if the rotation of the Quad is correct. Rotate Quad if needed.
Two perpendicular quads with flame sprites.
  • Assign the MeshRenderers from the newly created Quads to the ExhaustFlashMesh Renderers list.
Assigning Textures

To make flames look more convincing a random texture is assigned to each Quad on each flash. A number of default textures is included.

  • Assign textures to Flash Textures list.
Flash Textures list.
Adding Point Lights

If the material used for exhaust flash is not emisive adittional PointLight(s) can be added to light the surrounding area on flash.

  • Set up a PointLight and place it at the exhaust location.
  • After configuring, disable the light.
  • Add the light to the Flash Lights list.
Flash Lights list.
2023/05/14 16:35

Exhaust Smoke

ExhaustSmoke inspector.

ExhaustSmoke controls exhaust ParticleSystem color, size and emission speed. It interpolates between NormalColor and SootColor based on engine state.

Setup

  • Position ParticleSystems at vehicle exhaust position. Prefab of pre-configured ParticleSystem comes with the asset (Effects > Particles > Prefabs).
  • Assign the ParticleSystems to the Particle Systems list inside ExhaustSmoke inspector.
2023/05/14 16:35
LightsManager inspector.

LightsManager is tasked with turning VehicleLights on or off depending on user input.

Vehicle Light

VehicleLight inspector.

VehicleLight is a collection of LightSources. When the light is turned on all LightSources are turned on and vice versa.

2023/05/14 16:35
2023/05/14 16:35

Skidmark Manager

SkidmarkManager inspector.

Skidmarks are generated when wheel skids / slips over a surface.

  • Skidmarks are achieved by procedurally generating a mesh. One mark consists of two triangles and the number of triangles per one section can be calculated as Max Marks Per Section * 2.
  • Min Distance is the distance a wheel needs to travel before a new mark is created.
  • Default behavior is to delete the oldest triangles as soon as number of marks reaches Max Marks Per Section - similar to the old snake game. To make this transition smooth Fade Over Distance can be enabled or Peristent Skidmarks can be used. Check the section below for more info.
  • If skidmarks are not visible or clip into the terain GrounOffset needs to be increased.
  • To define when the wheel is slipping Longitudinal Slip Threshold and Lateral Slip Threshold from vehicle settings tab are used.
Surface-based Skidmarks
  • Skidmarks use settings of currently active SurfacePreset to get the settings for the current surface type.
Skidmark section of AsphaltTireFrictionPreset.
Persistent Skidmarks
Persistent skidmarks enabled.
  • Persistent skidmarks get stored into sections of Max Marks Per Section size.
  • Sections do not get destroyed as longs as the the player is under Peristent Skidmark Destroy Distance.
  • Downside to this approach is that over time this will cause the number of triangles in the view-port to increase.
2023/05/14 16:35

Surface Particle Manager

SurfaceParticleManager inspector.

SurfaceParticleManager creates and manages particles based on current SurfacePreset settings.

  • Particles are emitted on per-wheel basis. Total surface particle count is a sum of particle counts from all the wheels' ParticleSystems.
  • Lateral Slip Threshold and Longitudinal Slip Threshold under Settings tab determine the lowest wheel slip threshold needed for wheel to be considered to be slipping. This affects particle effects.
2023/05/14 16:35

Mirrors

Mirrors are set up through a combination of Cameras, RenderTextures and Materials with specific UV mapping.
Camera first renders its view to a RenderTexture which is assigned to a Material(any shader that supports albedo map will work). This Material has an UV map that corresponds to the surface of the vehicle mirror.

Possible setups are:

  • Render each mirror with a separate Camera to a separate RenderTexture which is assigned to a separate Material. Best visual quality but slow.
  • Using UV map that is split between the mirrors which means that each mirror gets only a part of the UV map, but this comes at a disadvantage that the interior of the vehicle can not be seen in rearview mirror since the camera needs to start rendering at the rear of the vehicle to prevent intersection with the vehicle mesh.
  • Hybrid approach: one camera for rearview mirror and one camera for left and right mirrors.


2023/05/16 09:27 · nwhcoding