I’m trying to create a boundary for my Pawn similar to Pixel Ship. The ship can only move so far left or right and since I’m making the same kind of game that is exactly what I need to do. However, I don’t see any logic in the blueprint that stops the pawn from moving passed the edge of the screen. Can anyone help me out with this? How is it being done in Pixel Ship? I see a box shape named Trigger that seems to be the boundary box as well and I’ve copied all the settings of the Trigger to my own box shape, but it had no effect on my game.
In that case the ship’s movement is only limited by the level collision, while the trigger at the bottom is just for destroying enemies that reach the floor. It looks like it you’re stopped before you reach the edges, but if you type “Show collision” into the console while playing the game, you’ll be able to see the simplified collision for both the ship and the environment.
In the Blueprint itself, the “Set actor location” function responsible for movement has a checkbox labelled “Sweep”, which is enabled. This basically just prevents movement if something is in the way, provided the Blueprint has collision enabled and has a simplified collision model. Does that help at all?
I don’t know Pixel Ship (is that one of the examples?) but I had a similar problem. Hold the pawn inside the camera view. I found it the easiest to hold camera and pawn in place and move everything else. With a orthographic camera at 0, 0, 1000 and a orthographic with of 3k you have a moveable area 1500 left, 1500 right and with a aspect ratio of 1.77 about 900 up and down. You can just clamp the movement to this values and you are done.
A Moving Ship and a moving camera should work the same way. The only problem is that if there is no input from the player you have to make sure to hold the player visible so if he hits the border you have to set his speed the same speed as the camera is moving. Also a perspective camera should just be a little bit of math to get the camera constraints.
There are several ways you could do this. One way would be to get the players X and Y position and use a clamp to limit it’s movement in those directions! Like i said there are several ways to accomplish this. Just depends on your needs.
That actually sheds a lot of light on the subject. I didn’t know about the “show collision” command. And I didn’t even notice sweep was checked. Thank you much.
Yeah, Pixel Ship is located in the Content Examples in the Blueprint_Input_Examples level. I didn’t even think about using clamp. Right now I’m just using a Branch node to make sure the ship isn’t out of bounds. Thanks for the suggestion.