0 Favourites

# Struggling with a math formula

• 5 posts

edit: I figured it out. It's ceil(currenthealth/maxhealth*28).

I actually had explored this before, but it was with the width of a sprite, rather than the frame number of an animation, so I kinda got confused. sorry if this topic caused any trouble!

• deleted

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

Construct 3 users don't see these ads
• So the frame and health ratios are the same so:

Health/maxHealth = frame/28

Solving for frame:

Frame = Health*28/maxHealth

Next we need to round it to a whole number, and since we want frame 0 to be used only if the health is 0 we will use ceil() to round up.

So the formula is:

Frame = ceil(Health*28/maxHealth)

• So the frame and health ratios are the same so:

Health/maxHealth = frame/28

Solving for frame:

Frame = Health*28/maxHealth

Next we need to round it to a whole number, and since we want frame 0 to be used only if the health is 0 we will use ceil() to round up.

So the formula is:

Frame = ceil(Health*28/maxHealth)

I figured it out on my own, but thanks anyway! It seems like the majority of the people here are nice! That's another newbie problem solved! Wish me luck as I move along with my game, I might post more questions along the way!

• yes we are here to help if we can

• 5 posts