Graphics Reference
In-Depth Information
correspondingGroundHit is a new WheelHit formed with the specific purpose of
getting to the sidewaysSlip value of the WheelCollider. If its value falls outside a certain
threshold, the wheels must be sliding enough to merit some tire smoke to be instantiated:
// define a wheelhit object, this stores all of the data from the
// wheel collider and will allow us to determine
// the slip of the tire.
WheelHit correspondingGroundHit= new WheelHit();
To fill correspondingGroundHit with the information from this wheel's WheelCollider,
the WheelCollider.GetGroundHit() function is used with correspondingGroundHit:
CorrespondingCollider.GetGroundHit( out correspondingGroundHit );
// if the slip of the tire is greater than 2.0f, and the slip
// prefab exists, create an instance of it on the ground at
// a zero rotation.
if ( Mathf.Abs( correspondingGroundHit.sidewaysSlip ) >
slipAmountForTireSmoke ) {
if ( slipPrefab ) {
Note that the slipPrefab will be instantiated every step (every update) that the side-
waysSlip value is above the value of slipAmountForTireSmoke. If your tire smoke particle
effect is complex, this could be a big slowdown point. For more complex effects, consider
staggering the effect based on a timer or simplifying the particle effect itself.
The tire smoke will be instantiated at the point of contact between the ground and the
wheel, but its rotation is not matched to the wheel:
SpawnController.Instance.Spawn( slipPrefab,
correspondingGroundHit.point, zeroRotation );
}
}
}
}
At this stage, the framework is loaded up for players and movement controllers. In the
next chapter, it's time to add some weaponry to the framework.
Search WWH ::




Custom Search