I’m working on a top-down 2d dungeon crawler. I added GraphUpdateObjects to various environmental setPieces (pits, spikes, etc) such that in their start routine they update the tags for the nodes they overlap.
var bounds = GetComponent().bounds;
bounds.Expand(.6f); //Tags the points surrounding the spike to make sure Enemies give them a wide berth.
guo = new GraphUpdateObject(bounds);
guo.modifyTag = true;
guo.setTag = spikeTag;
guo.updatePhysics = false;
AstarPath.active.UpdateGraphs(guo);
This worked fine, until I needed to rotate my spikes and pit traps. So I tried to add GraphUpdateShapes:
//Get local points based on the collider
GetBoxCollider2DPointsLocal(collider, out Vector3[] points);
Matrix4x4 matrix = transform.localToWorldMatrix;
var shape = new GraphUpdateShape(points, true, matrix, .1f);
guo.shape = shape;
AstarPath.active.UpdateGraphs(guo);
And it’s not working. I see a 4 year old post that GraphUpdateShapes were build to only work in the XZ plane. What can I do in light of that?
I rooted around in GraphUpdateShapes, and saw it was using XZ functions from VectorMath and Polygon, so I attempted to create an XY version of GraphUpdateShapes.Contains, but it doesn’t work, and it’s so mathy, I don’t know where to begin.