1

I want to know the time left to complete the animation as I am using unity asset Lean Tween to scale down my time bar, so when 5 seconds are left till the time run out I want to play sound of closing time. I was able to know when the animation is gonna end LeanTween.scaleX(timebar.gameObject, 1f, time).setOnComplete(this.Gameover) but how i can a get time left to complete? I have looked through documentation but didn't find anything useful.

derHugo
  • 83,094
  • 9
  • 75
  • 115
Umer Asghar
  • 127
  • 1
  • 2
  • 10
  • @MaifeeUlAsad didn't you read the question? Both in header and description of question, OP states, question related to **LeanTween** library not Unity animation. LeanTween library, modify components of object directly, don't create animations. – SeLeCtRa Feb 25 '21 at 09:18

1 Answers1

3

Every LeanTween function returns an instance of LtDescr class. This class has access to variable of animation and methods that can control it. You can get total time by time and passed time by passed. Remained time equal to time-passed.

LtDescr animation = LeanTween.scaleX(timebar.gameObject, 1f, time).setOnComplete(this.Gameover);
var remainedTime = animation.time - animation.passed;
SeLeCtRa
  • 600
  • 1
  • 6
  • 14
  • i know about this, but the time field only gives me the total time not the time left like is there any way i can get some vale while the leantween animation is running? – Umer Asghar Feb 25 '21 at 09:49
  • @UmerAsghar sorry for misinfo. Try to use **time-passed** instead of **time**. I also updated the answer. – SeLeCtRa Feb 25 '21 at 10:03