Moving player with touch event in a large map


Hi there, I’m trying to do a Diablo 2 moving style, where the player is always on the center of the screen and when you click or touch he moves and the camara follows him.
I can normalize my vector and move the player, I also can follow him with the camara.
But, when I reach to any of the coordinates where it’s out of bounds of the application window (ex: 1280x720), the coursor won’t track position far outside these bounds.
What is the solution to this? It’s there any native solution in Defold? Or what is the common practice to aproach this kind of movement?



Doesn’t sound like a problem with Defold, probably you have a faulty logic in your coordinate calculations.

1 Like


Are you converting from mouse screen positions to world positions when you calculate the movement direction vector?

1 Like


I just was thinking about this. No, I’m not. Just googling about it, if you have any info or links at hand would be nice, but I’m researching now.



Make a small example project where it happens and upload it here as a zip.



You need to keep track of the offset your camera has moved from 0,0 and add the offset to the mouse position.



Yes, I didn’t know that “screen to world coordinates” were a thing.
Last night I was checking the Orthographic camera API and make it work with that, you made that, right? It’s really good.
Any case, I think that I’m in the right path for now, thanks for taking the time in helping.