How do I make the camera only go up?

Get help using Construct 2

Post » Tue Jul 15, 2014 9:51 pm

Hello, I have a problem where I've set up a camera such as 1. System Every Tick > Set Scroll Y to Player.Y-100
and it's working fine for my game which is a doodle jump clone however I need the camera to only go vertical upwards and not follow the Player if he falls which would take him off screen and trigger the game over screen.

Is there an easy fix for this preferably which uses up a few events?

Kind Regards, Johan Blixt.
B
3
Posts: 4
Reputation: 435

Post » Tue Jul 15, 2014 10:11 pm

Just a quick tought, have a variable like cameraHeight, as the player goes up, add the player's speed to that variable, (never subtract from that variable) then set the camera to scroll to that variable on the Y axis. I think you get the idea. You need to check if that works.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Tue Jul 15, 2014 10:27 pm

@caiorosisca I don't quite understand what you mean but I did fiddle around with it abit and I don't understand what the speed is for? I made a camera such as 1. Every tick > set scroll Y to cameraHeight and a GlobalVariable called cameraHeight and set it to player.platform.speed.

Incase I was unclear on my premise the camera I need is one that only moves upwards if the player does and also never goes downwards, I don't quite need a constant scrolling either.

Thanks for your response tho!
B
3
Posts: 4
Reputation: 435

Post » Wed Jul 16, 2014 12:52 pm

bump?
B
3
Posts: 4
Reputation: 435

Post » Wed Jul 16, 2014 1:11 pm

Check this capx :
You do not have the required permissions to view the files attached to this post.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Wed Jul 16, 2014 1:13 pm

@johanblixt

Try setting cameraHeight to max(cameraHeight,player.Height)

e.g.

Every tick
set cameraHeight to max(cameraHeight,player.Height)
set scroll Y to cameraHeight

That way it increases when the player moves up, but never goes down.
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864

Post » Wed Jul 16, 2014 2:08 pm

My idea was something like @OddConfection said, having a variable that only goes up (you might need to check if the player vectorY is positive so you don't add negative values to the variable, not sure if speed is negative when going downards).
Imagine it like this player speed is 10, variable starts at 0, you add te speed(10) to the variable, scroll camera to the variable. On next frame camera will be at position 10, that keeps on going until you start falling, Imagine you kept it going until you reached 100 height, if you don't subtract values from that variable it will stay at Height 100, then you can check if distance between playerY and cameraY is greater than X value to check if he died.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Wed Jul 16, 2014 6:55 pm

@OddConfection
I feel like I'm missing something, when setting it up like you said it tells me cameraHeight needs to be an object? I have it set as a global variable, I just can't get it to work!
I appreciate your input tho
B
3
Posts: 4
Reputation: 435

Post » Thu Jul 17, 2014 10:17 am

@johanblixt

Here's a capx example:
CameraMoveUp.capx


In my post before I had put set cameraHeight to max(cameraHeight,player.Height) when it should have been Set cameraHeight to min(cameraHeight,Player.Y), since you want the Y position and Y is 0 at the top.
You do not have the required permissions to view the files attached to this post.
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests