Description
The LerpTo
method is used to interpolate the properties of the current GradientFogController
instance towards the properties of a specified target GradientFogController
instance. This interpolation is controlled by a delta value, which determines the interpolation speed, and an optional clamping parameter to restrict the interpolation within certain bounds.
Usage
To use the LerpTo
method, you need to have two instances of GradientFogController
. The method will adjust the properties of the current instance to move towards the properties of the desired
instance. The delta
parameter controls how quickly the interpolation occurs, with a value of 0 resulting in no change and a value of 1 resulting in an immediate change to the target properties. The clamp
parameter, when set to true
, ensures that the interpolated values do not exceed the bounds defined by the start and end properties of the fog.
Example
// Create two GradientFogController instances
GradientFogController currentFog = new GradientFogController
{
StartDistance = 10.0f,
EndDistance = 100.0f,
Color = Color.White
};
GradientFogController targetFog = new GradientFogController
{
StartDistance = 20.0f,
EndDistance = 150.0f,
Color = Color.Gray
};
// Interpolate currentFog towards targetFog
float delta = 0.5f; // Interpolation speed
bool clamp = true; // Clamp the values
currentFog = currentFog.LerpTo(targetFog, delta, clamp);
// After calling LerpTo, currentFog's properties will be halfway between its original values and targetFog's values.