Swipe style camera movement?

Siren Games

  • *
  • Posts: 102
Hey guys.  I've been toying around with this camera system for about an hour and i just can't seem to wrap my head around how to get it to work.  So before I drive myself crazy or scrap the idea I thought I'd post here and see if some more intelligent folk could help me out.

I have a large scene (larger than the screen size) and I'm trying to enable a click and drag camera system.  So when you click the mouse on the map and drag left, the camera moves to the right, not unlike navigating a mobile device.  Basically wherever the mouse clicks should feel like it's holding the map and moving it's position about.  I don't need any sort of momentum on it so the camera can stop moving the instant the mouse button is released.

Currently I'm using an actor I'm calling CameraController which spawns in the center of the screen position using X and Y mouse + camera x and y position.  Then on that actor I'm using When Updating that checks if the mouse is down and setting the x and y position of the actor to (And this is the part I'm wrong) x of mouse - screen width and y of mouse - screen height.  Now, the dragging to move thing works perfect. If I click and drag the camera moves exactly right and is very smooth. 

The issue is that every time I click it takes my camera back to the top left of the map each time.  I can't seem to figure out how to prevent this from happening.  I've tried adding the x and y of camera to the x and y of mouse, but that causes worse issues of the screen jumping around like crazy.

Any ideas?

squeeb

  • Posts: 1617
I think I may have a scroll function like that.. I'll find it tonight if it's what you need
Check the gif.. sorry no time to put it somewhere haha

Siren Games

  • *
  • Posts: 102
Yeah, that's exactly what I'm looking for, but in 4 directions.  Which shouldn't be much different.  If you wouldn't mind posting it when you can I'd seriously appreciate being able to look through how you did it.

squeeb

  • Posts: 1617
For sure.. I'll get it to you here in about 4 hours.. away from my laptop  at the moment

LIBERADO

  • *
  • Posts: 2720
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

squeeb

  • Posts: 1617
Yes! That's the one!  Works well!  Shouldn't be hard to go 4 way