Restrict the camera following an actor on only its X axis

beefy_clyrobeefy_clyro Member Posts: 5,394
edited November -1 in Working with GS (Mac)
Hi Guys. Bit of a problem - I have a game where it launches a ball and has a camera follow the ball. The problem is, to achieve the length needed, the ball needs to go high, this is fine until it goes too far out of the scene and the actor is destroyed. I thought i would then just make the scene very tall, this stops the actor being destroyed but as the camera follows it shows the blank parts off scene where the user should not see. So, i guess i need to create a tall scene but have the actor only follow its X position. Not sure if this is the best way or how to achieve that.

Anyone have any ideas how i can get around this?

Thanks

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    To have it just follow the x first take the control camera behavior out of the ball.

    Create a real game attribute called game.BallX

    In the ball constrain game.BallX to self.position.X

    Then create an invisible non-movable actor called cameraRules

    Drag this actor into a scene and unlock it.

    Drag a constrain behavior into the actor. Constrain CurrentScene camera.origin.X to game.ballX-240
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    You may also want to add this:

    create game.BallY and constrain it to self.position.Y of the ball

    in the cameraRules actor instance add this:

    constrain camera.Origin.Y to min(800,(game.BallY+(camera.height/2)))

    This makes it follow the ball with it centered in the screen until the origin reaches 800 and then it will go no higher. When the ball drops below the upper limit it will start following it again. You can put whatever number works for the 800.
  • davesfarmdavesfarm Member Posts: 14
    Im confused on the Camera Rules actor, is that just a normal actor named CameraRules? also... constrain behavior, do you mean constrain Atribute? when you mean invisible, you mean just turn the alpha on?

    When I do this, i cant figure out how to add the game.BallX to self.position.X... where is this or how can I add this?

    what do you mean by 'non movable actor?' too :/ sorry new to this and not a learned programer so guessing a lot here hehe

    Im having a lot of trouble controlling the camera and its atributes and trying to learn that right now
  • davesfarmdavesfarm Member Posts: 14
    oh wierd, I think I get it... when you double click the actor in the scene so you have to unlock it, when you open the atributes or expressions, whichever their called there is one more choice, and you can do the constrain camera. in it.. but when you double click it from the menue on the left you cannot... why is that?

    thanks!
  • davesfarmdavesfarm Member Posts: 14
    davesfarm said:
    oh wierd, I think I get it... when you double click the actor in the scene so you have to unlock it, when you open the atributes or expressions, whichever their called there is one more choice, and you can do the constrain camera. in it.. but when you double click it from the menue on the left you cannot... why is that?

    thanks!

    davesfarm said:
    oh wierd, I think I get it... when you double click the actor in the scene so you have to unlock it, when you open the atributes or expressions, whichever their called there is one more choice, and you can do the constrain camera. in it.. but when you double click it from the menue on the left you cannot... why is that?

    thanks!

    Oh one more thing how do you add the: the cameraRules actor instance add this:

    constrain camera.Origin.Y to min(800,(game.BallY+(camera.height/2)))
Sign In or Register to comment.