How do I

  • I have a sprite with 3 animation frames. Iwant them to respond to the x axis of a controller as it is moves to the right. So when the value is between 1-20 it is on frame 1, 20-40 frame 2, 40-60 frame the ext...

    I put two conditions setting a minimum and maximum x analog number but I can't get it to work.

  • Hi,

    I don't know your project but there always several solutions.

    You could create 3 invisible sprites and say that when your player is overlapping a specific one of those then you play whichever frame you want.

  • When it is in steps of 20 ...

    And you have 3 frames (zero index)

    Then ... AnimationFrame = Max ( floor(value/20) , 2 )

    When you want to spread a range over 3 frames ....

    AMax = Maximum allowed analogue number.

    AMin = Minimum analogue number.

    ACur = analogue number at this moment.

    AMax - AMin = Range .. Now lets normalise those with as rule that Amax should return the value 2 (zero based)

    Ratio = 3 / Range

    Norm = Ratio * Acur

    Norm = (3/Range) * (ACur)

    Norm = (3/ (AMax - AMin) ) * (ACur)

    This returns numbers with decimals, animation frame will not take numbers with decimals, so we have to round that number.

    So

    AnimationFrame = Floor(Norm)

    AnimationFrame = Floor((3/ (AMax - AMin) ) * (ACur))

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How do i input ACur? I cant find a way to put the analogue value in the equation.

  • ACur = analogue number at this moment / x axis of a controller at this moment

    I assume that you know how to read the controller.

  • Thanks. It worked.

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