ProceduralPlanets

◆ AnimateFloat()

void ProceduralPlanets.Planet.AnimateFloat ( string  _key,
float  _source,
float  _destination,
float  _duration,
float  _delay 
)

Animates a float after a delay from a source value to a destination value over the time of duration.

Animating shader features is fast - animating procedural materials is slow!

It is not recommended to have PlanetManager Texture Detail set to any of the Progressive modes if you plan to animate non-shader based properties.

Refer to the ProceduralPlanets_Properties.PDF documentation for a full reference of property names. The reference also states if a property is a shader feature (fast to animate) or which procedural materials need to be rebuilt (slow).

Parameters
_keyThe camelCase name of a property float - refer to the ProceduralPlanets_Properties.PDF documentation for a full reference of property names.
_sourceSource float value.
_destinationDestination/Target float value.
_durationTime it should take for the animation.
_delayDelay after which the animation starts.


using System.Collections;
using System.Collections.Generic;
// Attach this script to a Gas planet and it will animate some properties over 60 seconds with a 2 second delayed start.
// IMPORTANT: It is strongly recommended to set PlanetManager Texture Detail to anything else than progressive in the inspector.
{
public class AnimateGasPlanet : MonoBehaviour
{
Planet _planet;
void Start()
{
// Get a reference to the Gas planet
_planet = GetComponent<GasPlanet>();
if (_planet == null)
{
Debug.LogError("Not a gas planet. Aborting!");
return;
}
// Cache the procedural properties - should increase performance
_planet.CacheProceduralProperty("tubulenceDisorder", true);
_planet.CacheProceduralProperty("stormScale", true);
_planet.CacheProceduralProperty("stormNoise", true);
_planet.CacheProceduralProperty("turbulence", true);
// Initiate animation of properties: <propertyKey>, <from_value>, <to_value>, <duration>, <delay>
_planet.AnimateFloat("turbulenceDisorder", 0.0f, 1.0f, 60f, 2.0f);
_planet.AnimateFloat("stormScale", 0.1f, 0.6f, 60f, 2.0f);
_planet.AnimateFloat("stormNoise", 0.05f, 0.35f, 60f, 2.0f);
_planet.AnimateFloat("turbulence", 0.2f, 0.8f, 60f, 2.0f);
}
}
}