Search Unity

Changing sprite throught a fixed time X

Discussion in '2D' started by FedericoDellAquila, Sep 23, 2016.

  1. FedericoDellAquila

    FedericoDellAquila

    Joined:
    Nov 28, 2015
    Posts:
    16
    Hi all! We are working on a 2D platform, and we got stuck with an animation problem. We have a platform that change sprite through time, but it's not always a fixed time. I'll try to explain this the best I can.

    Our character have the power to activate certain platform overing the mouse over it and pressing Left Shift. These platform, initially, will be trasparent so that the player will know he/she can't intereact with it. Once activated, two things gonna happen: the platform will become completly visibile and the player can jump over it, and a little countdown will appear at the center of the platform. This countdown is a sort of gem splitted in 5 portions, and through time, each pieces will disappear. When all of them are gone, the platform will go back to its intangibile form, and the entire proces can be repeated at will. The problem is that we can't figure out how to set a script that allow us to create a coherent animation for the countdown, no matter how long this gonna be. The platform can be tangible for 1 second, 3 seconds, 5 seconds, X seconds. How can we create a countdown that is gonna remove all the pieces of the gem through that X time?

    Maybe we can create a system that will keep track of the X time and at fixed value, like x*1/5, x*2/5 and so on, and every time we reach one of these point, the sprite will change. Suggestions?
     
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    It comes down to removing a gem portion every (#Portions / totalSeconds) seconds.