- Home /
Question by
laurienash · May 02, 2015 at 10:17 PM ·
javascriptcoroutinefunction updatebasic programming
Set plane to active for 1.5 seconds when camera is active called continuously - how to only call once?
Hi - in my scene I switch between two terrains on pressing the right mouse key button.
Each time the camera is set to active in each terrain I would like a plane overlaying the camera view (which is parented to the camera) to be set to active for 1.5 seconds.
I've written this script, but the problem is that the update calls the function continuously, so the plane is continuously set to active and inactive every 1.5 seconds whilst the camera is active.
How do I change this script so that it is only called once?
var woodCamera : GameObject;
var staticPlane : GameObject;
function Update () {
if (woodCamera.activeInHierarchy == true);
staticOverlay () ;
}
function staticOverlay () {
staticPlane.active = true;
yield WaitForSeconds (1.5);
staticPlane.active = false;
yield;
}
Best, Laurien
Comment