Hello!
I’m working on a 2D TD strategy RPG.
At the start of the project, I had a choice at the time between having a contractor use his own “lightweight” A* or using this. To my dismay, he talked me into using his.
One year and a half later, where he’s not even on the project anymore and I’ve built upon it – I’m suffering huge lag times for things like calculating paths and movement ranges. Tried to multithread it using the Jobs System, but as you know, Unity’s API isn’t thread-safe (so I can only wonder what black magic you did to get this multithreaded).
I am forced to roll with our existing solution in the short term, but I would REALLY like to move to using this plugin’s Grid Graphs over my 16x16 tilemaps.
Before I create a branch and gut our pathfinding – I wanted to touch base about our current system and how we could accomplish our needs using Pro.
- Entities that take > 1 Cell
As you can see in the video – our units are typically 2x2.
We have a WorldGrid class that’s on top of our tilemap and uses Unity’s built-in Grid component. We use it to store unit positions in Vector2Int
and often do Grid.WorldToCell
or Grid.GetCellCenterWorld
to switch between grid cell positions and world Vector3 positions.
I was wondering how occupation of nodes in grid graph works? Is it based on 2D physics – do I need to draw a Box Collider 2D over where the units are?
Also, we have units that are irregular non-perfect squares. Based on if they are looking Up/Down or Left/Right, the will be 2x3 or 3x2.
The grid cells it occupies are calculated from it’s origin in the bottom left.
Is there a way to programmatically set this?
- Marking Nodes as Impassible
My guess is that you’d use physics typically to mark nodes as impassible. In our game, each tile in the tilemap is a WorldCell – that has loads of data about the tile.
It’s travel cost, passability from certain directions, whether it blocks LOS or not:
Can we set travel costs for nodes in the graph, based on if it overlaps with a WorldCell’s position? Set it as unable to enter from certain sides?
- Line of Sight
I saw elsewhere that there is no built-in solution for this. Which is okay.
I only need to know if we can: Draw a line between two nodes and return a list of the nodes in order.
I believe I’ve seen this while parsing the forums.
- Determining Movement Ranges
Each unit has a Movement stat that defines their balance for moving on the grid by travel cost. For instance, just an int of 15.
I’ll need to get a list of nodes that are traversable within the range of 15.
I guess my final question: is Aron Granburg open to contract work? (haha, it’s worth asking!).
I’m certain I can get this done with your support but I figured it’s worth asking