How do I scroll camera only when player turns around

  • Hey. Trying to get a smooth camera going. I'm using a lerp command now, it does the job nicely, but my character is jittering about when he's walking. I'm guessing this has something to do with pixel rounding being on and using lerp with every tick, so I have to try something else.

    I have a limited Gameboy screen to work with, so I wanna give my player as much space to see incoming baddies as possible, so I always have the camera 40 pixels ahead of him. This works fine except when I turn around, the camera snaps to 40 pixels to the left, which is really jarring.

    With lerp

    No lerp

    Is there any way to smooth this movement out without using lerp on every tick? I just want the camera moving from side to side to smooth out, then it can go solid after the switch.

    Thanks for the help.

  • hey there, this is what i would do.

    You need 1 variable to store the lerping ammunt, let call this one "num".

    So when the player is not mirrored (going right), you add 0.1 to num as long as it is < 1.

    when the player is mirrored (going left), you substract 0.1 from num, as long as it is > 0.

    and then you scroll.X to: lerp( player.X - 40 , player.X + 40 , num)

    I hope it's what you wanted. There is no reason this should flicker, and using lerp every thick should not be a problem either.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hey there, this is what i would do.

    You need 1 variable to store the lerping ammunt, let call this one "num".

    So when the player is not mirrored (going right), you add 0.1 to num as long as it is < 1.

    when the player is mirrored (going left), you substract 0.1 from num, as long as it is > 0.

    and then you scroll.X to: lerp( player.X - 40 , player.X + 40 , num)

    I hope it's what you wanted. There is no reason this should flicker, and using lerp every thick should not be a problem either.

    Thanks, chap. I'll give it a go!

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