Graphics Reference
In-Depth Information
SendMessage() call is SendMessageOptions.DontRequireReceiver, which stops any warn-
ings if the message is not received:
// tell spawned object to use this waypoint controller
tempObj.SendMessage("SetWayController",waypointControl,Send
MessageOptions.DontRequireReceiver);
If shouldSetSpeed is set to true, this function will attempt to set the speed of the
new  object based on the value of speedToSet. As with setting the waypoint controller,
gameObject.SendMessage() is used to tell the object about the speed rather than having to
find a specific script and call a function on it:
// tell object to use this speed (again with no required
// receiver just in case)
if(shouldSetSpeed)
tempObj.SendMessage("SetSpeed",speedToSet,SendMessage
Options.DontRequireReceiver);
When shouldSetSmoothing is true, gameObject.SendMessage() is used to send a
smoothing rate to a function named SetPathSmoothingRate. This will affect how quickly
the objects/enemies turn on the path:
// tell object to use this speed (again with no required
// receiver just in case)
if(shouldSetSmoothing)
tempObj.SendMessage("SetPathSmoothingRate",smoothingToSet,
SendMessageOptions.DontRequireReceiver);
If shouldSetRotateSpeed is true, gameObject.SendMessage() attempts to send the
rotate speed value (from the variable rotateToSet) to a function called SetRotateSpeed():
// tell object to use this speed (again with no required
// receiver just in case)
if(shouldSetRotateSpeed)
tempObj.SendMessage("SetRotateSpeed",rotateToSet,SendMessage
Options.DontRequireReceiver);
Now that spawning and setup have finished, we increase the spawnCounter and
currentObjectNum counters:
// increase the 'how many objects we have spawned' counter
spawnCounter++;
// increase the 'which object to spawn' counter
currentObjectNum++;
The variable currentObjectNum is used to point which object to spawn next in the
array of objects to be spawned. When it reaches the value of totalSpawnObjects−1, that's
the top end of the array and it needs to be reset back to zero:
// check to see if we've reached the end of the spawn
// objects array
Search WWH ::




Custom Search