Animation Frame based in a Variable

0 favourites
  • 2 posts
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • Hello! I trying to find a formula to calculate and set the frame of the animation in a sprite, but i can't.

    Basically, i have a sprite with 5 frames, 0 is empty, then there is 1, 2, 3 and 4.

    They are cracks that get bigger in crescent order, then i have a Max_HP and Actual_HP for the object, hp that decreases when i hit the object(Block) with a weapon using another variable in the weapon that represents the strength, so i did this:

    Set Block animation frame = MaxHP - ActualHP, if both is 5, then it works very well, but what if i wanted another object with more MaxHP/HP, i can't create a specific animation for every 1 unit of HP.

    So my question is, how do i make the frames match with the remaining HP for every object, like 8 HP but having only 5 frames?

    I can't find a solution.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Try this:

    Set frame to round(lerp(4, 0, HP/MaxHP))

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)