How do I scroll camera only when player turns around

Get help using Construct 2

Post » Tue Aug 11, 2015 6:11 pm

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
Image

No lerp
Image

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.
B
7
S
2
Posts: 60
Reputation: 604

Post » Wed Aug 12, 2015 6:41 am

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.
B
43
S
12
G
6
Posts: 446
Reputation: 6,807

Post » Wed Aug 12, 2015 7:27 am

Sargas wrote: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!
B
7
S
2
Posts: 60
Reputation: 604


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests