Announcement

Collapse
No announcement yet.

Cant get camera to pan when dragging on screen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    Click image for larger version

Name:	camera.png
Views:	1
Size:	387.3 KB
ID:	1208888

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

    #2
    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
    Click image for larger version

Name:	Controller.PNG
Views:	1
Size:	367.1 KB
ID:	1122572
    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):
    Click image for larger version

Name:	Scrollfunction.PNG
Views:	1
Size:	242.4 KB
ID:	1122573
    "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.

    2) Camera Pawn - This is a Bluprint with type "Pawn" i has a scene component, a spring arm and a camera
    Click image for larger version

Name:	Camera.PNG
Views:	1
Size:	324.3 KB
ID:	1122574
    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

    Comment


      #3
      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:

      https://forums.unrealengine.com/show...l=1#post651252

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

      https://forums.unrealengine.com/show...l=1#post522690
      ----------------------------------------------------------------------------------------------------------
      What are the BEST Unreal Tutorials / Docs? There are none tbh... Here's why
      Instead its better to just take projects apart (see the free 'creators' listed here)

      Comment


        #4
        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?

        Comment


          #5
          Originally posted by franktech View Post
          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:

          https://forums.unrealengine.com/show...l=1#post651252

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

          https://forums.unrealengine.com/show...l=1#post522690
          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

          Comment

          Working...
          X