Is there a way to make a sort of tap and drag camera thing like in Google Maps? I'm trying to make a replica of a game I used to play as a kid and I need that sorta feature to look around.
I searched around and didn't seem to find anything except one action that's called "Drag Camera" but that one is sorta directional, I'm looking for like if you tap and drag on Google Maps. Thanks.
== SOLUTION ==
This took way longer for me to solve than expected but it's made to work on any size phone and be consistently the same moving speed.
So, first, there are 3 states in a loop. The first one is just checking the input for a
Mouse Down or
Touch if ya like. But it's got nothing really in it. I'll list the rest in paragraphs because there's a lot more in those. But the diagram looks like this.
Touch Down:
Enter: this state is checking a lot of things, it get's the height (H) and width (W) of the screen, position of the mouse normalized, then converts that normalized mouse coordinates to convert the mouse coordinates in the editor by dividing the H with W for the screen ration. Then, it stores all the mouse coordinates there just for
Button Down, so this is all happening in one frame and one frame only. Ends with a
Next Frame Event. As well as storing the main camera's position in a variable.
Diagram:
Move: this is kinda the tough part, it get's the same information as the last state except in realtime, and constantly updates where the current mouse position is in editor coordinates. Then it gets the difference of the two and moves the main camera according to those two coordinates, adding the difference at the end of the loop, then to not move the camera exponentially it has to subtract the difference right after the camera is moved because it adds the difference right before. This state only finishes when the
Button Up event is called. Then when it gets out it loops back to the
Mouse Down event.
Diagram:
Probably not the best solution, but it's the solution I came up with. Catch ya'll later!