Support Forum

Resize the grid according to the size of the enemy

When I scan I set collider diameter to 1 but some enemy walk through the buildings being very large, how can I fix it?

Hi

A collider diameter of 1 corresponds to it being as large as the width of one node.

Yes, I known; how can I do?

Hi

You can increase the diameter to a value greater than one perhaps?

Yes, but there are both small and large enemies.

Hi

You can use multiple graphs for that.
This will require you to either use a custom movement script or modify the existing ones a bit. You will have to add the graphMask parameter to the seeker.StartPath call.

See these threads



Using multiple graphs does not affect performance?

It primarily increases the scanning time and memory usage. However pathfinding performance is not significantly affected.

Thanks! I have another problem: enemies overlap and here I have generated a random path but they try to pass through the building, failing; I assigned to the building the ‘TransparentFX’ layer the same as the ‘obstacle layer mask’

hi! If I understand correctly, then for each enemy with a different collider diameter, is it required to create a new graph?
and to find the path use the mask GraphMask.FromGraphName(“Diamert2”);
Right?

Yes. You can read more about that here: Multiple agent types - A* Pathfinding Project

sorry for the possibly stupid question, but i cant find answer.
I work from scripts, and i have for example 3 enemy. two have a radius “2” and other “3”. I need to find a suitable graph on initialization enemy and if it does not exist create a new one.

  1. how to create a new graph correctly?
  2. how to find the right graph so as not to create duplicates for each?

Resolve my problem.
Create graph like this:

	AstarData data = AstarPath.active.data;
	GridGraph gg = data.AddGraph(typeof(GridGraph)) as GridGraph;
	int width = 40;
	int depth = 40;
	float nodeSize = 1;
	gg.center = Vector3.zero;
	gg.SetDimensions(width, depth, nodeSize);
	gg.collision.diameter = _radius * 2;
	gg.collision.type = ColliderType.Capsule;
	gg.collision.mask = _obst;
	gg.collision.heightCheck = false;
	_mask = GraphMask.FromGraph(gg);
	AstarPath.active.Scan(gg);

And after save _mask in my Dictionary.
Thank you a lot!
Best wishes

1 Like