Difference between revisions of "RadarDetector"
(Initial page, includes API information and categories) |
Latest revision as of 16:24, 20 April 2013
This implements a radar detection system. By itself it doesn't display anything; instead it provides hooks to allow other classes to determine how the radar should be displayed. In the toolbox, RadarDisplay2d uses this script to draw the radar on a 2d plane.
Contents |
[edit] Public Variables
[edit] worldStyle : WorldStyle
This is how the world is set up. It can have the following values.
[edit] WORLD_IS_2D
This is where the player moves in the X, Y direction and the camera view, as shown in the Unity editor, is showing the Back view.
[edit] WORLD_IS_3D
This is where the player moves in the X, Z coordinate system and jumps in the Y.
[edit] centerObjectTag : string
This is used to automatically set the object that should be at the center of the radar.
[edit] centerObject : GameObject
This is the object to be used as the center object in the radar. If it's null when the script starts, the object with the tag above will be used. If the tag is also not set when the script starts, the script will use the object it's attached to as the center object.
[edit] targetTag : string
This is the tag of the objects that this detector will track.
[edit] Targets : GameObject[]
This returns the current list of targets being tracked. Read-only.
[edit] updateInterval : float
This is how often the UpdateTargets function will be run.
[edit] range : float
This is how close to the center object the targets must be to be detected.
[edit] Events
As previously mentioned, this script exposes some hooks that allow other classes to use it to display the radar information.
[edit] event DoDrawTarget drawTargetCallback
This event will be called for every target object within range. It has the following function signature:
public delegate void DoDrawTarget (Vector2 pos, GameObject obj);
[edit] PrePostDrawTarget
Both of the following events have the same function signature:
public delegate void PrePostDrawTarget ();
[edit] event PrePostDrawTarget preDrawTargetCallback
This event will be called before any targets are drawn.
[edit] event PrePostDrawTarget postDrawTargetCallback
This event will be called after all targets are drawn.
[edit] Public Functions
[edit] void UpdateTargets ()
This manually updates the list of targets. It is exposed as a public function in case other display classes want to take care of when to update the targets. It uses GameObject.FindGameObjectsWithTag to get the targets objects, so it probably shouldn't be called every frame.