日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

快速开发实用工具VRTK-011

發(fā)布時(shí)間:2023/12/31 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 快速开发实用工具VRTK-011 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

011_CameraRig_HeadSetCollisionFading 穿墻檢測(cè)

防穿墻功能,穿墻就變黑(自定義顏色)

新建一個(gè)EmptyObject 命名為PlayArea ,并掛載相應(yīng)的腳本。

核心腳本 VRTK_HeadsetCollision:檢測(cè)碰撞,同時(shí)定義了HeadsetCollisionDetect和HeadsetCollisionEnded事件。

核心腳本 VRTK_HeadsetFade: 定義了陰影效果的實(shí)現(xiàn)。陰影的開始完成;陰影的褪去完成。HeadsetFadeStart,HeadsetFadeComplete,HeadsetUnfadeStart和HeadsetUnfadeComplete。

核心腳本VRTK_Headset Collision Fade:

探測(cè)什么時(shí)候用戶的VR頭盔與其他游戲?qū)ο蟀l(fā)生碰撞,并且在探測(cè)到碰撞的時(shí)候淡入屏幕到一個(gè)單色。這樣是為了處理那些把頭部放進(jìn)游戲?qū)ο?#xff08;例如墻體、門、柜子)中進(jìn)行透視的情況,但我們并不希望玩家發(fā)現(xiàn)這樣的穿幫。

頭盔與游戲?qū)ο蟀l(fā)生碰撞時(shí)發(fā)出OnHeadsetCollisionDetect事件,表示探測(cè)到頭盔碰撞;停止碰撞時(shí),發(fā)出OnHeadsetCollisionEnded事件。

// Headset Collision Fade|Presence|70030 namespace VRTK {using UnityEngine;/// <summary>/// 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./// </summary>/// <remarks>/// 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.////// The Headset Collision Fade uses a composition of the Headset Collision and Headset Fade scripts to derive the desired behaviour./// </remarks>/// <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./// </example>[RequireComponent(typeof(VRTK_HeadsetCollision)), RequireComponent(typeof(VRTK_HeadsetFade))][AddComponentMenu("VRTK/Scripts/Presence/VRTK_HeadsetCollisionFade")]public class VRTK_HeadsetCollisionFade : MonoBehaviour{[Header("Collision Fade Settings")][Tooltip("The amount of time to wait until a fade occurs.")]public float timeTillFade = 0f;[Tooltip("The fade blink speed on collision.")]public float blinkTransitionSpeed = 0.1f;[Tooltip("The colour to fade the headset to on collision.")]public Color fadeColor = Color.black;[Header("Custom Settings")][Tooltip("The VRTK Headset Collision script to use when determining headset collisions. If this is left blank then the script will need to be applied to the same GameObject.")]public VRTK_HeadsetCollision headsetCollision;[Tooltip("The VRTK Headset Fade script to use when fading the headset. If this is left blank then the script will need to be applied to the same GameObject.")]public VRTK_HeadsetFade headsetFade;protected virtual void OnEnable(){headsetFade = (headsetFade != null ? headsetFade : GetComponentInChildren<VRTK_HeadsetFade>());headsetCollision = (headsetCollision != null ? headsetCollision : GetComponentInChildren<VRTK_HeadsetCollision>());headsetCollision.HeadsetCollisionDetect += new HeadsetCollisionEventHandler(OnHeadsetCollisionDetect);headsetCollision.HeadsetCollisionEnded += new HeadsetCollisionEventHandler(OnHeadsetCollisionEnded);}protected virtual void OnDisable(){headsetCollision.HeadsetCollisionDetect -= new HeadsetCollisionEventHandler(OnHeadsetCollisionDetect);headsetCollision.HeadsetCollisionEnded -= new HeadsetCollisionEventHandler(OnHeadsetCollisionEnded);}/// <summary>/// 發(fā)生碰撞/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected virtual void OnHeadsetCollisionDetect(object sender, HeadsetCollisionEventArgs e){Invoke("StartFade", timeTillFade);}/// <summary>/// 碰撞結(jié)束/// </summary>/// <param name="sender"></param>/// <param name="e"></param>protected virtual void OnHeadsetCollisionEnded(object sender, HeadsetCollisionEventArgs e){CancelInvoke("StartFade");headsetFade.Unfade(blinkTransitionSpeed);}/// <summary>/// 陰影效果/// </summary>protected virtual void StartFade(){headsetFade.Fade(fadeColor, blinkTransitionSpeed);}} }

?

總結(jié)

以上是生活随笔為你收集整理的快速开发实用工具VRTK-011的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。