How would you make mouse click movement work only on Cartesian co-ordinates?

As some may have gathered I’ve been doing some detailed research into isometric games and how they’re made, I have pretty much everything sorted now except for one thing. Is it possible to do mouse click movement where the character only follows cartesian co-ordinates?

There are two steps to this:

  1. convert the mouse click into an integer cell location (I assume that’s what you intend). For the above application, when you generate the above grid, I would put a little MonoBehavior on each cell identifying it, such as (0,0), (1,0), etc. When you click on it, if you hit the collider, you look for that identifier, and voila, you have integer X,Y.

  2. quantize the character’s motion so that they move (usually with a coroutine, but you could snap instantly) only to identified positions.

To help you in this, I would make a centralized mechanism that converts between the world coordinates and your integer pairs (x,y). If you make this a pair of static methods in a “WorldMetrics” class, and all the code uses that, then if you decide you want to increase the size of your grid by 20%, it’s a one-stop fix.

Thanks, I’ll take a look at all of that an see how the methods work, been learning tons this week.

You’d just need to write methods for converting to and from your Cartesian coordinate system and the Unity position systems. I do something similar in my MMO I’m building where ship locations are stored in the DB and represented to the player in latitude / longitude, which the server then converts to Unity world space position when placing the object in the scene, and converts back to lat/long when saving or updating the coordinates on the player’s minimap.

1 Like

It may help a little: Line drawing on a grid check out the 2nd section: Grid walking.

I can recommend Amit’s blog for every grid-type work, he curates the best algorithms for grid-problems since the nineties.