I started using A* recently and i am working on a RTS game. I am destroying terrain, and then recalculating the graph in the locations where its needed.
It dosnt do a perfect job but good enough, cause the units should still be able to walk in that crater since its not deep enough. Terrain destruction and update of graph
Now the problem arises when i try to leave some of the units inside the crater. cause they are trying to go up but towards the graph but there is no need for that, they can just fall down. Unit not falling towards the ground, keeps spasaming
My question is. is it possible to tell the Follower entity to stop trying to update the objects Y coordinate in the sense that the gravity still works but the entity stops trying to force y to go up?
Some solutions i was thinking about and wanted to hear your thoughts about them
Make the unit model not follow the entity, and make the entity not use the gravity, so the entity just follows the graph. And the unit model apply custom gravity to them and let them follow the entity X and Z positions only (might have problems with slopes)
Same as the first one only add a rigidbody that can only update the Y coordinate
Take the path thats calculated and change its Y coordinate in the sense for each point cast a ray downwards and tell the object that that is its new path coordinate (this doesnt make a lot of sense to me but its an idea)
You could always turn off Gravity for your units and then control their Y position directly. I think the answer to this depends on how craters affect your gameplay- if they are simply supposed to be “no-go” places then you have other better options. Let me know what you need out of this
Sry for the late replay. Units can pass trough the craters, but if the crater gets too deep they cant anymore.
In the end i decoupled the follower and the object (i told the follower not to update the position and rotation, doing that in another script + rigidbody), but i can already see an optimization problem in the future from that way (when there are a lot of units in the scene).
If i turn off gravity will it still go up? towards the follower?, or do you mean the y of the follower?
How would i go around doing that? i am trying to drag the FollowerEntity down on the Y as much as i can but its not going deep enough. Is there like a Y offset or something that i can make larger?
I would recommend reducing the tile size of the graph a bit. A lower tile size will break up the large triangles into smaller ones, which will better be able to represent the curvature of the terrain.
Kinda depends on your individual setup and requirements. It’s gotta be pretty dense and pretty large and running on pretty mid hardware before you’ll see performance hits. I’d say see if you’re running into any Astar related performance issues and we’ll see what your individual case needs. You can also read a bit more about tile size here.
Smaller tile sizes definitely come with a bit of overhead. But usually it’s not too bad.
Check the profiler to see if you can spot any differences.
I wouldn’t recommend going too far below tile sizes of 64, though, as the overhead adds up.