Ping pong is similar to a lerp function, except they bounce between value A and value B until they are told to stop.
From unity3d.com, their example is:
function Update ()
{
transform.position = Vector3(Mathf.PingPong(Time.time, 3), transform.position.y, transform.position.z);
}
The gameobject's position is being constatly updated and 'Mathf.PingPong(Time.time, 3)' is constatly changing between 0 and 3. As a result, the game object will be moving back and forth.
For use in my game, i wanted to animate my menu title a little.
function Update ()
{
transform.localScale = Vector3(11 - (Mathf.PingPong(Time.time*2, 1)),2 + (Mathf.PingPong(Time.time, 0.5)),0.1);
}
In Layman's terms the objects scale is constantly being changed to (ScaleX, ScaleY, ScaleZ).
Where ScaleX is 11 and being subtracted by 0.0-1.0, ScaleY is 2 and being added by 0.0-0.5 and ScaleZ is 0.1.
This gives the effect of the title being squashed in and out .
No comments:
Post a Comment