Download

Cant get camera to pan when dragging on screen

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.

camera.png

What am i doing wrong? Please keep in mind I have little experience with blueprints, so please explain things.

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:

  1. camera controller (used for screen border calculation and click events)
  2. camera pawn (placed in the level and is moving the camera around)

  1. Camera Controller
    Controller.PNG
    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):
8523afb5424eaa76bead57874a08db3931a9c890.png
“Mouse Scroll Threshhold” should be set to 0.1 -> This will determine how close the mouse has to be near the edge to start moving.

  1. Camera Pawn - This is a Bluprint with type “Pawn” i has a scene component, a spring arm and a camera
    Camera.PNG
    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.

Give it a try - i hope it will work for you.

Regards

There are many BP nodes that appear to do the same or similar things imo. So…
Sometimes its easier to start with something that works and then tweak that:

BTW: How come KorkuVeren isn’t helping you with this?

https://forums.unrealengine.com/showthread.php?109278-Poll-Would-you-buy-my-game&p=522690&viewfull=1#post522690

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.

Regards