I started with sidescroller BP template and I’m making a 2D vertical rocket game. The rocket will have left/right movement in the X axis while launching in Z. Right now my rocket freely moves left and right and my camera is centered on the character.
Eventually the camera will be fixed and the left/right movement wil be constrained to that 2D view space. How do I keep the rocket from going off the screen and bound to a fixed X range?
If you don’t need to go outside of what you can see in the screen, then a simple collision box that encompasses the viewable space should suffice. Personally I use a hollow static mesh that surrounds the area where my map is to be generated and only collides with the player/camera.
Another method would be to use < or > nodes that take a float derived from your vector, and compare it to the bounds you set for your play area. Basically if your rocket is near the edge of the screen then it branches false on the movement input. Of course this won’t stop your rocket from going offscreen if you have any kind of momentum, but for instance I use it to constrain my scroll distance and it works like a charm.
Il give the invisible mesh a shot tonight after work, thank you Zurstiak. The screen will be scrolling vertically , should I just make a left and right collision mesh that moves in Z with the character?
I do like the second option, but it won’t work for the physics based rocket when it is headed off the screen as you pointed out. Does sound like a great solution for bounded scroll area (makes me think of Angry Birds)
If you attach the volume to the camera you should be set.