Announcement

Collapse
No announcement yet.

Math time- Inverting a number?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Math time- Inverting a number?

    Hi!

    Is it even possible to invert a number like in range 100-0. Like I want to use opacity based on my player health. So if the player health is say 99 the opacity would be 0.01, and if the health is 50 the opacity would be 0.5

    What is the best way to do this and if people like math, they could help me with this? Or should I look into changing the way I approach this?

    #2
    1 - (currentHealth/maxHealth)
    Looking for blueprint tutorials? Then visit my blog... voxagon

    Comment


      #3
      Another option is "Map Range" with the In Range set to 0 - 100, and the Out Range set to 1.0 - 0.0

      Comment


        #4
        Inverting a result can also be accomplished by multiplying by -1.

        Comment


          #5
          Originally posted by DoteDote View Post
          Another option is "Map Range" with the In Range set to 0 - 100, and the Out Range set to 1.0 - 0.0
          I think this will do me fine thanks man! I needed this for other types of stuff as well :P

          Comment


            #6
            Originally posted by fanzypantz View Post
            So if the player health is say 99 the opacity would be 0.01, and if the health is 50 the opacity would be 0.5
            Am not a math expert but try this:

            Code:
            1 - (currentHealth / MaxHealth)
            So if your current health is 40 and max health is 100 then it will be like 1 - (40 / 100) which is 0.6

            If your current health is 600 and max health is 1000 then again it'll be like 1 - (600 / 1000) which is 0.4
            Support my RTS Game (Agora) on Patreon!
            Unreal Nexus - Create Share and Experience!
            Unreal Engine 4 World-Wide User Map

            [PLUGIN] Aws Gamelift Client Plugin
            [TOOL] Create your own binary release of UE4 from GitHub source
            My UE4 Tutorials and Misc Tools

            Lead Programmer at YetiTech Studios
            Your Friendly Neighborhood
            Satheesh PV (a.k.a RyanJon2040) | Twitter, Instagram, Facebook, LinkedIn, YouTube, Google+

            Comment


              #7
              Yeah I realized that when the other guy said that. Math skills have been unused for some years now :P

              Comment

              Working...
              X