How do I keep camera centered on character?

Get help using Construct 2

Post » Mon May 15, 2017 9:41 pm

Im working on a sidescroller platform game but I cant seem to get the camera to stay centered on my player character sprite I am using these: lerp(Self.X, Player.X,0.03) lerp(Self.Y, Player.Y,0.03) but with these settings the player mainly moves to the far right of the screen when I move right and the far left when I move him left
can anyone please tell me the settings to get my camera keep the character at the center when scrolling?
B
10
S
3
Posts: 14
Reputation: 678

Post » Mon May 15, 2017 10:53 pm

You can either use the System action Scroll to: Player.X, Player.Y, every tick

or

You can apply the Scroll To behavior to your Player
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Mon May 15, 2017 10:55 pm

If you only want the lateral movement and not the up and down. You can create a sprite name it "Camera", make it invisible and have it updating its X position to the player's X positon constantly and use the Scroll To Behavior on the camera sprite.
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,501

Post » Tue May 16, 2017 12:28 am

Thanks for replying I have the scroll behavior on the player,playerbox and the camera and I tried the settings you mentioned but the camera still wont stay in the center also when the player to the top platform at the end of the level the camera doesnt follow him up to the top of the layout would you guys have any idea why the camera wont scroll to the top of the layout?
B
10
S
3
Posts: 14
Reputation: 678

Post » Tue May 16, 2017 12:42 am

Yes, in the layout settings for that layout (on the left side of the C2 editor), you need to set "Unbounded Scrolling" to Yes. Otherwise, it will keep the viewport within the boundaries of the layout.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996


Return to How do I....?

Who is online

Users browsing this forum: blue visionary and 4 guests