Ground Detection
GroundDetection
is one of the most important aspects of NWH Vehicle Physics. It determines whichWheelFrictionPreset
will be used for calculating friction, which effects will be active, and which sounds will play. In short, it determines which wheel is on which surface.- Ground detection works based on
Terrain
texture indices and object tags so it is very important how many textures there are assigned to theTerrain
and in which order.
To prevent having to change the settings across all the vehicles GroundDetectionPreset
ScriptableObject
was introduced in NWH Vehicle Physics 2.
- NWH Vehicle Physics 2 supports ground detection with multiple
Terrain
s in one scene. GroundDetection
runs checks for a maximum of one wheel at a time. This is to improve on performance but it can introduce a small delay from the time the surface has been changed to the timeGroundDetection
registers it.
Ground Detection Preset
Surface Map
SurfaceMap
tellsGroundDetection
whichSurfacePreset
to use for which terrain texture and/or object tag.
GroundDetection
runs a check for eachWheelComponent
to determine which surface thatWheelComponent
is on. This is done by checking all the assignedSurfaceMap
s in order and if anySurfaceMap
has a matching terrain texture index inTerrain Texture Indices
list, or the object the wheel is on has the tag fromTags
list,Surface Preset
will be assigned to thatWheelComponent
.
Adding a New Surface Map
Adding a gravel SurfaceMap
will be used as an example.
- Add a new
SurfaceMap
by clicking on+
button on the bottom of the list. - Check on which texture positions are the gravel textures. In the image above that would be 5 and 7. Add those numbers to the
Terrain Texture Indices
list. - If there are objects that should represent gravel in the scene, assign a tag (e.g.
GravelRoad
) to those objects and add it toTags
list.
Surface Preset
SurfacePreset
tells the VehicleController
which settings to use for which surface.
This determines tire friction, the look of effects such as skidmarks and particle effects. It also changes sounds to match the surface.
Once set up, SurfacePreset
can be used for different terrains, scenes or even across games since SurfacePresets
do not carry any scene-specific fields.
Setup
- Right click on empty space in Project window and select
Create ⇒ NWH Vehicle Physics ⇒ Surface Preset
. This will create a newSurfacePreset
ScriptableObject
in the current directory. - Assign a name to it for easier debugging later.
Friction
- Assign a
Friction Preset
. This is aScriptableObject
with settings for tire friction so thatWheelController
can adjust its behavior according to the surface type. With asset come multipleFriction Preset
s so just pick one of those for now.
Skidmarks
- Adjust skidmark settings according to the surface type. More about skidmark settings on Skidmarks page.
Skidmark Material
will be used on generated skidmarks while the wheel is on this surface type.Slip Factor
determines if the skidmarks are slip dependent. On soft surfaces such as sand this value should be 0 as the skidmarks/thread-marks should always be visible, no matter the slip. On hard surfaces such as asphalt skidmarks are only visible when there is wheel slip.
Dust/Smoke Particles
ParticleType
-Smoke
should be used for hard surfaces (asphalt, concrete),Dust
for dusty surfaces (gravel, sand). The difference between the two is in the way the emission rates are calculated. IfSmoke
is selected this will be related to the wheel slip while it will depend on vehicle speed forDust
.Particle Life Distance
is used to calculateParticleSystem
'sStart Lifetime
. The faster the vehicle is going the shorter the lifetime of the particles will be.Max Particle Emission Rate Over Distance
determines amount of particles emitted over distance of one meter.Max Particle Lifetime
determines the absolute maximum time a particle can be alive. When still this value determines how long the particle lives. When movingParticle Life Distance
is used instead.
Chunk Particles
Chunk particles represent pieces of dirt, debris, sand or pebbles thrown behind the tire when there is wheel spin.
Depending on speed the lifetime of a a particle is calculated from Max Chunk Lifetime
(when near still) or Chunk Life Distance
(when moving).
Sounds
SkidSound
andSurfaceSound
settings are used to setWheelSkidComponent
andWheelTireNoiseComponent
SoundComponents values for current surface.