I have a camera looking down on my world and I want it to move when dragging, I dont want the camera to look around like in a 3D world, but instead like a 2D world on that kind of an axis. I cant seem to get it to work, here is my blueprint.
I assume you want something like an RTS style camera? I have a working prototype but im not so good in explaining. Well who cares, lets give it a try :).
This may look a bit overwhelming for you, but you get an working example and i personaly prefere to lern by reverse engineering other stuff. So lets get started:
I split my camera system in two parts:
camera controller (used for screen border calculation and click events)
camera pawn (placed in the level and is moving the camera around)
All required Variables should be visible in the picture, you don’t need “KlickPosition”, “SelectedMinion” and the Zoom related Stuff
“Get ScreenUpDown” and “Get ScreenLeftRight” are Inputs i asignt to the arrow keys. My camera can be moved by either using the arrow keys or by moving the cursor to the edge of the screen
For that i came up with the function “Get Mouse Scroll Input” (Pure function):
It has nothing under Event Graph. Just one function called “Scroll Screen”. Thats the one we use in the Camera Controller
The 4 Camborder Variables determine how far i can move the camera away from the center of the map.
The SpringArm and the camera a set so they above the pawn and look straight downwards.
You can ignore the Zoom related stuff here too.
I’ts just a top down view, the camera doesnt rotate at all, kind of like in super mario bros, the camera goes up down left and right, except this is top down, will that code work like that?
I can asure you this works. It does not look clear i know, but it was the only way i was able to detect screen borders for variable screen sizes.
Some nodes are duplicated since i need them for both axis.
My setup will move the screen when the input buttons are pressed or when the mouse cursor is near the edge of the screen.
But you can use almost anything else to let it move. You just need to connect your input logic to the “Scroll Screen” function.
Rotation is not implemented (yet), but should be easily done when using control rotation or sth. like that.