Showing Damaged Object by Percentage

  • This is something that I haven't figured out how to do properly in years and I would like to apply it to multiple projects I'm working on.

    I have an object that has HP. When its HP is lowered, I want the object to show cracks in it. The animation is simple but I don't understand how to calculate the damage percentage wise.

    What are the proper values to have an object show a certain cracked animation frame at 75%, 50% and 25%? And how would I adjust this to work with even more animation frames in the future?

    Any help would be appreciated.

  • Percentage of the hp to apply to any hp amount would be like :

    25% = maxhp*0.25

    50% = maxhp*0.5

    75% = maxhp*0.75

    To set animations based on this they would probably be a variable and you check between the values.

    So for first animation Is between 75% and 100% = is between maxhp*0.75 and maxhp

    second anim = is between maxhp*0.5 and maxhp*0.75

    third anim = is between maxhp*0.25 and maxhp*0.5

    final anim = less than max hp*0.25

    And so you don't have to keep writing formulas you can assign them variables :

    var1 = maxhp*0.25

    var2= maxhp*0.5 etc

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Percentage of the hp to apply to any hp amount would be like :

    25% = maxhp*0.25

    50% = maxhp*0.5

    75% = maxhp*0.75

    To set animations based on this they would probably be a variable and you check between the values.

    So for first animation Is between 75% and 100% = is between maxhp*0.75 and maxhp

    second anim = is between maxhp*0.5 and maxhp*0.75

    third anim = is between maxhp*0.25 and maxhp*0.5

    final anim = less than max hp*0.25

    And so you don't have to keep writing formulas you can assign them variables :

    var1 = maxhp*0.25

    var2= maxhp*0.5 etc

    OK, so I would have to create a variable of what the max HP of the object is first, then I can perform the calculation afterwards for the animation events. I'll give it a shot.

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