Guides
These docs are for v2.1.0. Click to read the latest docs for v3.3.0.

VRTK_HeadsetCollisionFade

Overview

The purpose of the Headset Collision Fade is to detect when the user's VR headset collides with another game object and fades the screen to a solid colour. This is to deal with a user putting their head into a game object and seeing the inside of the object clipping, which is an undesired effect.

The reasoning behind this is if the user puts their head where it shouldn't be, then fading to a colour (e.g. black) will make the user realise they've done something wrong and they'll probably naturally step backwards.

If the headset is colliding then the teleport action is also disabled to prevent cheating by clipping through walls.

Unity Version Information

  • If using Unity 5.3 or older then the Headset Collision Fade script is attached to the Camera (head) object within the [CameraRig] prefab.
  • If using Unity 5.4 or newer then the Headset Collision Fade script is attached to the Camera (eye) object within the [CameraRig]->Camera (head) prefab.

Inspector Parameters

  • Blink Transition Speed: The fade blink speed on collision.
  • Fade Color: The colour to fade the headset to on collision.
  • Ignore Target With Tag Or Class: A string that specifies an object Tag or the name of a Script attached to an obejct and will prevent the object from fading the headset view on collision.

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.

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

SteamVR_Unity_Toolkit/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.