# How to draw grid on plane.

Hi everyone!
I have a plane. And I have a crowd like picture below.
I want to arrange the crowd as much as possible into the plane below.
I plan to create a grib position where will be destination of agent and calculate the number that can be stored agents based on the plane size and agent size. (I just know size of box collider of plane and agent.
But I don’t know how to create points( draw a grib) on that plane. Please help me, thanks.
(Ps: I am try to make a game like

)

I would go with some custom path finding based on this paper.

Here is a example of what can be archived with it.

I am sure you can do this also some how with unitys build in path finding but good luck getting the results you want.

Thanks for reply, but I think I cant use AI pathfinding of navmesh.
Currently, I am stucking at create a list of position, create a grid on a plane. :((

Hi everyone.
I created a grid where can stored the largest number of agent. I want to it place at on floor. But it is in-correcting.
How can I fix it, thanks a lot!

``````  private void OnDrawGizmos()
{

Gizmos.color = Color.yellow;
int sizeX = Mathf.RoundToInt(transform.lossyScale.x / agent.lossyScale.x);
int sizeZ = Mathf.RoundToInt(transform.lossyScale.z / agent.lossyScale.z);

for (int i = 0; i < sizeX; i++)
{
for (int z = 0; z < sizeZ; z++)
{
var point = new Vector3(agent.lossyScale.x * i, 0f, agent.lossyScale.z * z);
Gizmos.DrawCube(transform.position + point, agent.lossyScale);

}
}
}
``````

You can use Unity - Scripting API: Transform.TransformPoint .

Create a new Vector3 (i,0,z) and multiply it with the GRIDOBJECT.transform.TransformPoint where the GRIDOBJECT is at the position where you want the grid to be pointing forward to the road.

EDIT: not sure maby Unity - Scripting API: Transform.TransformVector is the right one.

Also I guess its easier to align your objects to the grid then the grid to a object.

May be you should make a grid that represents the passenger area and vehicle at the same time this could save you some trouble later on.