Normalize number to between 0 and 1

0 favourites
  • 4 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • Hey all,

    I've been a member for a while - but this is my first forum post!   (Haven't needed to ask anything, since this community has answered almost everything for me!)

    My question - If i have a range, like say 234 - 1250, assuming 1250 is the max and 234 is the minimum. How could I take a third number, say Sprite.Physics.VelocityY and normalize the number to be between 0 and 1?

    I realize this is more of a math question than anything, but I'm curious if there is a Contruct-y way of doing this?

    If the answer is/was simple, then forgive me :P

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure what you need, but I'd try velocity *0.1

  • I see. Ok, well - clamp seems to only give either upper value or lower value depending on how close the variable is to either.

    lerp - well, still trying to wrap my head around lerp (and I suspect is probably what I need to use - still tinkering with it)

    but essentially, this is what I am trying to figure out:

    I have a character falling and falling. Velocity of the fall i have set to an upperbound of 1200. I have particles that trail behind (speed lines) but I want the opacity to increase as the rate of descent increases. Since opacity is between 0 and 1 - i'm looking for a way to convert my numbers (velocity, upperbound) to a value between zero and 1.

    Newt - thanks for the suggestion, but I have other uses and would like a more normalized number.

    my brain asplodes when looking at things like this:

  • I think I've got it:

    minBound is the lower number, maxBound is the higher

    (variable - minBound) / (maxBound-minBound)


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