- Home /
Mathf.Pingpong without the repetition!?
Using this to change materials in a transtition....but would like it to stop reverting back to the main material1 after. Is there another way other then Mathf.Pingpong or a way to stop if after getting material2???
// Blends between two materials
var material1 : Material;
var material2 : Material;
var duration = 5.0;
function Start () {
// At start, use the first material
renderer.material = material1;
}
function Update () {
// ping-pong between the materials over the duration
var lerp : float = Mathf.PingPong (Time.time, duration) / duration;
renderer.material.Lerp (material1, material2, lerp);
}
Comment
Answer by Wolfram · Jun 02, 2011 at 10:21 PM
You could just use Mathf.Clamp(). Or you take a look at iTween, a powerful script providing all sorts of interpolation/fading/transformation/animation functions.
Your answer
Follow this Question
Related Questions
Fade an object in and out 0 Answers
Mathf.PingPong from a random position problems 0 Answers
C# Mathf.PingPong Rotate Back and Forth 2 Answers
Ping pong position using lerp 3 Answers
How to get the property names from shader in runtime? 2 Answers