Unity: VR Head Blocking (Steam VR v2)
Fade color can be changed or disabled to produce a pure wall push back effect on impact. VRHeadBlocking.cs: // VR Head Blocking Script (Synaptic Response) // For use with SteamVR Unity Plugin v2 // Attach to Player -> FollowHead -> HeadCollider and set Tag to "Player" // Initial Implementation: Scott Lupton (04.18.2020) using System.Collections; using System.Collections.Generic; using UnityEngine; using Valve.VR; public class VRHeadBlocking : MonoBehaviour { public GameObject player; [SerializeField] bool fadeEnabled = true ; [SerializeField] Color fadeColor = Color.black; private int layerMask; private Collider[] objs = new Collider[ 10 ]; private Vector3 prevHeadPos; private int fadeState = 0 ; private float fadeDuration = . 5f ; private float internalFadeTimer = 0f ; private float backupCap = . 2f ; private void Start () { ...