Component > Dialogue System > Actor > Player > Selector
Selector provides an interface for the player to target "usables" and send "OnUse" messages to them.
Property | Function |
---|---|
Layer Mask | The layer mask to use when targeting objects. Objects on others layers are ignored |
Select At | How to target (center of screen or under mouse cursor). Default is center of screen |
Distance From | How to compute range to targeted object. Default is from the camera |
Max Selection Distance | The max selection distance. The selector won't target objects farther than this. Usables also have their own Max Selection Distance |
Raycast All | Tick to check all objects within the raycast range for usables. If unticked, the check stops on the first hit, even if it's not a usable. This prevents selection through walls |
Use Default GUI | If ticked, use a default OnGUI to display a selection message and targeting reticle |
Gui Skin | The GUI skin to use for the target's information (name and use message) |
Gui Style Name | (Not shown) The style in the GUI skin. Defaults to label |
Alignment | (Not shown) The text alignment |
Text Style | The text style for the name and use message |
Text Style Color | The color of the text style's outline or shadow |
In Range Color | The color of the information labels when the target is in range |
Out Of Range Color | The color of the information labels when the target is out of range |
Reticle | The targeting reticle images |
Use Key | The key that sends an OnUse message |
Use Button | The button that sends an OnUse message |
Default Use Message | The default use message. This can be overridden in the target's Usable component |
Broadcast To Children | If ticked, the OnUse message is broadcast to the usable object's children |
Actor Transform | (Not shown) The actor from which this message is sent. If not set, defaults to the Selector's transform |
Too Far Message | (Not shown) If not blank, this message is shown as an alert if the player tries to use a target that's too far |
Debug | If ticked, draws raycast gizmos to show what the selector sees |
The Selector finds targets by raycasting from a specified source such as the current mouse position or the center of the screen. If the raycast hits a collider that also has a Usable component, the Selector displays a targeting message, and the player can press a button or key to send an "OnUse" message.
The usable can handle the "OnUse" message by starting a conversation, playing a cutscene sequence, etc., typically by using a trigger component such as Conversation Trigger.
You can add modifier components such as Selector Follow Target or Unity UI Selector Display to change the selector's display behavior.
When the player targets a Usable and presses the Use Key or Use Button, the Selector will send an OnUse(Transform player)
message to the usable GameObject. The Dialogue System's triggers, such as Conversation Trigger, respond to this message. Your own scripts can also respond to this message by adding an OnUse method such as:
<< Components