Click and Drag Camera System (Updated link on latest comment)

After a couple hours I finally figured out how to make a click and drag camera so you can play a world in the third person and be able to view the world without a character.

I’m sure many of you have already made this or have made it before, which wouldn’t be surprising. But here is my version of it.

I was planning on making a tycoon type game and now I have a proper camera system to use for it. Not for sure how long this game will be an example for, but feel free to use it for the time being.

This also works for mobile too.

14 Likes

Nice Maniac Pumpkin this could be used for a rpg game, or one of those strategy games!

4 Likes

@grazer if I polish up the code and art a bit, would it make the examples page?

Knowing full responsibility that I can’t edit it or use it as testing other than updates afterwards.

Unless someone already made a better version.

3 Likes

The old Link don’t work since I repurposed the game for another project, but here is a more updated version of it. I still need to update it a bit, but this is the new official example for anyone who needs it.

I also used Dinodev’s idea for the grid background, but I plan to add borders so the camera can be limited to a set area and the ability to zoom in and out.

I’m a little bored at the moment so I may work on this example. I think I have an idea to include zoom in and out functions while also allowing proportional movement. There are issues that zooming or expanding the window will mess up the drag distance and will skip around.

Here’s the link again. For some reason the zoom feature ended up working just from removing old code. Apparently, the game fixed itself after some updates, since I haven’t worked on this project for about a year or so now.

I added a keybind so you can toggle between light and darkmode. And added fullscreen functions. I’m not sure what else I’ll add because I don’t want to include a ton of extra stuff or mechanics, but just a simple example.

After a bit, I’ll drop this in a new discussion, so the link above doesn’t get mistaken for the new one.