RadarDetector

From Headbone Creative
Jump to: navigation, search

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

Public Variables

worldStyle : WorldStyle

This is how the world is set up. It can have the following values.

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.

WORLD_IS_3D

This is where the player moves in the X, Z coordinate system and jumps in the Y.

centerObjectTag : string

This is used to automatically set the object that should be at the center of the radar.

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.

targetTag : string

This is the tag of the objects that this detector will track.

Targets : GameObject[]

This returns the current list of targets being tracked. Read-only.

updateInterval : float

This is how often the UpdateTargets function will be run.

range : float

This is how close to the center object the targets must be to be detected.

Events

As previously mentioned, this script exposes some hooks that allow other classes to use it to display the radar information.

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);

PrePostDrawTarget

Both of the following events have the same function signature:

  public delegate void PrePostDrawTarget ();

event PrePostDrawTarget preDrawTargetCallback

This event will be called before any targets are drawn.

event PrePostDrawTarget postDrawTargetCallback

This event will be called after all targets are drawn.

Public Functions

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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox