Maths problem for your brain

0 favourites
  • 5 posts
From the Asset Store
Brain Games is a series of challenges, riddles and puzzles.
  • Hello dear community of C2

    I have a complex (for me) maths problem that I can't wrap my head around... I think it must involve using lerp(a,b,x) but I'm not quite sure how to achieve this..

    I have two objects. Object A must influence Object B.

    Object A moves from speed 0 to 100

    Object B has a size of 36 x 36

    Now I want the size of Object B to adapt according to the speed of Object A on a scale.

    The fastest Object A goes, the flattest and widest Object B gets. when Object A's speed is maximum (100) Object B must have a width of 150 from initial width of 36

    and height of 3 from initial height of 36 (kinda like a jelly cube which would flatten and spread then go back to its original size.

    So when Object A's speed = 0 Object B size = 36 x 36. When object A's speed is 100 then Object B size = 150 width x 3 height

    Which gives us:

    OBJECT A SPEED RANGE: 0___________________________________100

    OBJECT B WIDTH RANGE: 36_________________________________150

    OBJET B HEIGHT RANGE: 36__________________________________3

    If Object A's speed = 50, then Object B Width should be 57 and Height 16,5. How can I obtain both those numbers dynamically? I'm pretty sure lerp must be used..

    I'm not sure if the example I've used is very clear. My brain is melting even tho I suspect it's not THAT complicated

  • If A's speed is 50, and if its a linear evolution, then B width should be 93, not 57 and height should be 19.5, not 16.5.

    Check again.

    The formula can be something like this:

    B.width = 36 + (A.speed * 1,14);

    B.height = 36 - (A.speed * 0,33);

    Edit: re-read and i think you want it to change exponentially, right? Let's wait then

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cassianno You are absolutely right! I checked and it works! I feel very stupid now. Lerp not even needed! Hahah

    Thank you very much for your help Cassianno!

  • Woot, nice =)


    1,14 = (150-36)/100

    0,33 = (3-36)/100

  • Thanks, I need that formula more often than I think and I always end up doing more complicated stuff than necessary.

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