Game Development Reference
In-Depth Information
Engage thrusters
Let's get started:
1. Go to the folder (for C# users, go to Chapter6 | Scenes | C# | Waypoint and for
JavaScript users, go to Chapter6 | Scenes | JavaScript | Waypoint ) in the Project
view, and then right-click and choose (for C# users) Create | C# Script or (for
JavaScript users) Create | JavaScript and rename it to Waypoint .
2. Double-click on the Waypoint script to open it in MonoDevelop and start creating
the waypoint, which will only have the OnGizmos() function to show the icon
image and the wire sphere for the radius of the waypoint as follows:
// Unity JavaScript user:
#pragma strict
private var _radius : float;
private var _showGizmos : boolean;
function OnDrawGizmos ()
{
if (transform.parent != null) {
if
(transform.parent.GetComponent.<WaypointsContainer>()
!= null) {
_showGizmos =
transform.parent.GetComponent.<WaypointsContainer>().showPath;
if (_showGizmos) {
_radius =
transform.parent.GetComponent.<WaypointsContainer>().radius;
Gizmos.color = Color.green;
Gizmos.DrawIcon(transform.position,
"wayIcon.psd");
Gizmos.DrawWireSphere (transform.position,
_radius);
}
}
}
Search WWH ::




Custom Search