Waypoint problem

Hello,
I am trying to make a navMesh with waypoints. So far I am adding the waypoints to the level and putting them in an empty GameObject so they are grouped.

The problem is placing waypoints by hand is slow. I want to place an empty GameObject in the scene, attach a script, set the width and height variable in the script, and with the @ContextMenu() call a function in the editor to place them evenly in the width and height from my GameObject.

My questions are:

  1. How do I add the Waypoint prefab to the GameObject in code after I instantiate it? I know how to add components, but I don’t see a way to add children.

EDIT:
I tested #2 and I can save them, I just need to know answer to #1.
/EDIT
2. After I add the waypoint to the GameObject can I save them in the scene so they are there when I open the scene again?

I am going to continue to try to figure it out, but any help would be nice.

Thanks,
Taylor

Set the parent property of the transform.

e.g. if you want to set the Waypoint to be a child of the empty GameObject you would do:
waypoint.transform.parent = emptyObject.transform;

Now if you move the emptyObject the waypoint will follow.

Thank you, I will give that a try.

EDIT:
Thank you Shaneo, that worked great.
/EDIT

-Taylor

http://angryant.com/path/