How do I make the camera only go up?

0 favourites
  • 9 posts
From the Asset Store
The ultimate voice pack filled with 1,536 files of .......wav and mp3 of individual numbers, letters, and words (that go
  • 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.

  • 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.

  • 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!

  • bump?

  • Check this capx :

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • johanblixt

    Here's a capx example:

    [attachment=0:gwrpt6eu][/attachment:gwrpt6eu]

    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.

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