-
Notifications
You must be signed in to change notification settings - Fork 0
Using Interactable Objects
[VRTK_InteractUse]
The Interact Use script is attached to a Controller object
within the [CameraRig] prefab and the Controller object
requires the VRTK_ControllerEvents script to be attached as it
uses this for listening to the controller button events for using
and stop using interactable game objects. It listens for the
AliasUseOn and AliasUseOff events to determine when an object
should be used and should stop using.
The Controller object also requires the VRTK_InteractTouch script
to be attached to it as this is used to determine when an interactable
object is being touched. Only valid touched objects can be used.
An object can be used if the Controller touches a game object which
contains the VRTK_InteractableObject script and has the flag
isUsable set to true.
If a valid interactable object is usable then pressing the set
Use button on the Controller (default is Trigger) will call the
StartUsing method on the touched interactable object.
The following script parameters are available:
- Hide Controller On Use: Hides the controller model when a valid use action starts
- Hide Controller Delay: The amount of seconds to wait before hiding the controller on use.
The following events are emitted:
- ControllerUseInteractableObject: Emitted when a valid object starts being used
- ControllerUnuseInteractableObject: Emitted when a valid object stops being used
The event payload that is emitted contains:
- controllerIndex: The index of the controller doing the interaction
- target: The GameObject of the interactable object that is being interacted with by the controller
An example can be viewed in the scene
SteamVR_Unity_Toolkit/Examples/006_Controller_UsingADoor. Which
simulates using a door object to open and close it. It also has a cube
on the floor that can be grabbed to show how interactable objects can
be usable or grabbable.
Another example can be viewed in the scene
SteamVR_Unity_Toolkit/Examples/008_Controller_UsingAGrabbedObject
which shows that objects can be grabbed with one button and used with
another (e.g. firing a gun).
- Home
- Quick Start
- FAQ/Troubleshooting
- Prefabs
-
Scripts
- Controllers
- Pointers
- Movement
- Interactions
- Examples