Hello there,
I trying to add timer to my time bar, the way I constructed my timer is by using a “3d plane” and transfrom the postion from “start to end” position, and if the “3d plane” reach the “end” position the game will end.
this is my script :
#pragma downcast
#pragma strict
#pragma implicit
//MASKING GAMEOBJECT//
public var masking : Transform;
//MASKING VECTOR FROM START TO END//
public var start : Vector2 = Vector2.right;
public var end : Vector2 = Vector2.right;
public var addTimer : Vector2 = Vector2.right;
//MASKING TIME SPEED//
public var speed : float;
public var t : float;
function Update ()
{
TimerDrop ();
}
function TimerDrop ()
{
t += Time.deltaTime * speed;
masking.position = Vector2.Lerp (start, end, t);
GameOver ();
}
function GameOver ()
{
if (masking.position == end)
{
print ("gameOver");
}
}
what I want to do now is, when I push a button the “3d plane” will add value to “A” position as if the time is adding. I tried using this but seems not working:
function AddTimer ()
{
masking.position += addTimer;
}