Hi all,
I want to draw 4 points around my object. I use these point as destination of my nav mesh agent.
I use this script to draw them (with Gizmos):
private void InitWaypionts()
{
Vector3 size = this.gameObject.GetComponent<Renderer>().bounds.size;
Vector3 position = this.transform.position;
actionPoints = new Vector3[4];
actionPoints[0] = new Vector3(position.x - (size.x / 2) - 0.2f, position.y, position.z);
actionPoints[1] = new Vector3(position.x + (size.x / 2) + 0.2f, position.y, position.z);
actionPoints[2] = new Vector3(position.x, position.y, position.z - (size.z / 2) - 0.2f);
actionPoints[3] = new Vector3(position.x, position.y, position.z + (size.z / 2) + 0.2f);
}
void OnDrawGizmos()
{
if (actionPoints != null && actionPoints.Length > 1)
{
Gizmos.color = Color.yellow;
Gizmos.DrawSphere(actionPoints[0], 0.1f);
Gizmos.color = Color.blue;
Gizmos.DrawSphere(actionPoints[1], 0.1f);
Gizmos.color = Color.red;
Gizmos.DrawSphere(actionPoints[2], 0.1f);
Gizmos.color = Color.green;
Gizmos.DrawSphere(actionPoints[3], 0.1f);
}
}
The result is:
I have a problem if the object has a rotation, in this case the points are drawn in wrong position:
How I can apply the rotation of these points, to draw them correctly?