VRTK_HeadsetCollision
Overview
The purpose of the Headset Collision is to detect when the user's VR headset collides with another game object.
Unity Version Information
- If using
Unity 5.3
or older then the Headset Collision script is attached to theCamera(head)
object within the[CameraRig]
prefab.- If using
Unity 5.4
or newer then the Headset Collision script is attached to theCamera(eye)
object within the[CameraRig]->Camera(head)
prefab.
Inspector Parameters
- Ignore Target With Tag Or Class: A string that specifies an object Tag or the name of a Script attached to an object and will be ignored on headset collision.
- Target Tag Or Script List Policy: A specified VRTK_TagOrScriptPolicyList to use to determine whether any objects will be acted upon by the Headset Collision. If a list is provided then the 'Ignore Target With Tag Or Class' parameter will be ignored.
Class Events
HeadsetCollisionDetect
- Emitted when the user's headset collides with another game object.HeadsetCollisionEnded
- Emitted when the user's headset stops colliding with a game object.
Unity Events
Adding the VRTK_HeadsetCollision_UnityEvents
component to VRTK_HeadsetCollision
object allows access to UnityEvents
that will react identically to the Class Events.
OnHeadsetCollisionDetect
- Emits the HeadsetCollisionDetect class event.OnHeadsetCollisionEnded
- Emits the HeadsetCollisionEnded class event.
Event Payload
Collider collider
- The Collider of the game object the headset has collided with.Transform currentTransform
- The current Transform of the object that the Headset Collision Fade script is attached to (Camera).
Class Methods
IsColliding/0
public virtual bool IsColliding()
- Parameters
- none
- Returns
bool
- Returns true if the headset is currently colliding with a valid game object.
The IsColliding method is used to determine if the headset is currently colliding with a valid game object and returns true if it is and false if it is not colliding with anything or an invalid game object.
Example
VRTK/Examples/011_Camera_HeadSetCollisionFading
has collidable walls around the play area and if the user puts their head into any of the walls then the headset will fade to black.
Updated less than a minute ago