Restrict the camera following an actor on only its X axis
beefy_clyro
Member Posts: 5,394
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
Anyone have any ideas how i can get around this?
Thanks
Comments
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
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.
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
thanks!
constrain camera.Origin.Y to min(800,(game.BallY+(camera.height/2)))