[AR/VR教程] SteamVR Unity工具包(二):激光和移动

news/2024/2/27 21:06:11

Simple Laser Pointer (VRTK_SimplePointer)
简单激光指针(VRTK_ SimplePointer

The Simple Pointer emits a coloured beam from the end of the controller to simulate a laser beam. It can be useful for pointing to objects within a scene and it can also determine the object it is pointing at and the distance the object is from the controller the beam is being emitted from.

简单指针(Simple Pointer)脚本从控制器尾部发出一个有色光束来模拟激光束。这在场景中指向对象很有用,它能判断所指向的对象以及对象距控制器发出光束位置的距离。


The laser beam is activated by default by pressing the Grip on the controller. The event it is listening for is the AliasPointerevents so the pointer toggle button can be set by changing the Pointer Toggle button on the VRTK_ControllerEvents script parameters.

激光束默认按下控制器的抓握键(Grip)来激活。因为所侦听的事件是AliasPointer别名事件,所以这个指针开关按钮可以通过在 VRTK_ControllerEvents脚本参数里来改变 pointerToggleButton来选择设置。

The Simple Pointer script is attached to a Controller object within the [CameraRig] prefab and the Controller object also requires the VRTK_ControllerEvents script to be attached as it uses this for listening to the controller button events for enabling and disabling the beam.
Simple Pointer
简单指针脚本(VRTK_ SimplePointer)添加到[CameraRig] 预制里的控制器对象上,同时添加需要VRTK_ControllerEvents脚本来监听启用和禁用光束的控制器按钮事件。


The following script parameters are available:
下面是可用脚本参数:


· Enable Teleport: If this is checked then the teleport flag is set to true in the Destination Set event so teleport scripts will know whether to action the new destination. This allows controller beams to be enabled on a controller but never trigger a teleport (if this option is unchecked).
· Pointer Hit Color: The colour of the beam when it is colliding with a valid target. It can be set to a different colour for each controller.
· Pointer Miss Color: The colour of the beam when it is not hitting a valid target. It can be set to a different colour for each controller.
· Show Play Area Cursor: If this is enabled then the play area boundaries are displayed at the tip of the pointer beam in the current pointer colour.
· Play Area Cursor Dimensions: Determines the size of the play area cursor and collider. If the values are left as zero then the Play Area Cursor will be sized to the calibrated Play Area space.
· Handle Play Area Cursor Collisions: If this is ticked then if the play area cursor is colliding with any other object then the pointer colour will change to the Pointer Miss Color and the WorldPointerDestinationSet event will not be triggered, which will prevent teleporting into areas where the play area will collide.
· Beam Always On: If this is checked the the pointer beam is always visible but the Destination Set event is still only emitted when the assigned button is pressed.Activate Delay: The time in seconds to delay the pointer beam being able to be active again. Useful for preventing constant teleportation.
· Pointer Thickness: The thickness and length of the beam can also be set on the script as well as the ability to toggle the sphere beam tip that is displayed at the end of the beam (to represent a cursor).
· Pointer Length: The distance the beam will project before stopping.
· Show Pointer Tip: Toggle whether the cursor is shown on the end of the pointer beam.

· Enable Teleport(启用传送):如果勾选了,在目标设置事件中的teleport标志位就设为true,所以传送脚本就知道是否要行动到新的目标。如果这个选项没有勾选的话,控制器光束启动但是不会触发位移。

· Point Hit Color(指针碰撞颜色):当光束和一个有效目标碰撞的颜色。每个控制器可以有不同的颜色设置。

· Pointer Miss Color(指针无碰撞颜色):当光束没有命中有效目标时的颜色。每个控制器可以有不同的颜色设置。

· Show Play Area Cursor(显示游玩区光标):如果这个启动,游玩区界限就会在光束指针的顶端显示出来,颜色和当前指针颜色相同。

· Play Area Cursor Dimensions(游玩去光标尺寸):决定游玩区光标和碰撞的尺寸。如果值为零,Play Area Cursor 的尺寸将根据Play Area空间进行校正。

· Handle Play Area Cursor Collisions(处理游玩区光标碰撞):如果勾选,当游玩区光标和其他物体发生碰撞时,指针颜色就会变成Pointer Miss Color的颜色且WorldPointerDestinationSet 事件将不会被触发,这将防止传送到游玩区会发生碰撞的区域。

· Beam Always On(光束总是开启):如果这个勾选,光束指针总是可见,但是设置目标点事件仍然只会在所指定按钮松开时发出。

· Pointer Thickness(指针光束厚度):光束长宽也可以在脚本里设置以及能够开关显示在光柱最后的球形光柱顶端(表示光标)。

· Pointer Length(指针光束长度):在停止前光束投射的距离。

· Show Pointer Tip(显示指针顶端):切换是否光标显示在光束指针的尾部。



The Simple Pointer object extends the VRTK_WorldPointer abstract class and therefore emits the same events and payload.

简单指针对象扩展自VRTK_WorldPointer 抽象类并因此发出相同的事件和有效数据。

An example of the VRTK_SimplePointer script can be viewed in the sceneSteamVR_Unity_Toolkit/Examples/003_Controller_SimplePointer and code examples of how the events are utilised and listened to can be viewed in the scriptSteamVR_Unity_Toolkit/Examples/Resources/Scripts/VRTK_ControllerPointerEvents_ListenerExample.cs

VRTK_SimplePointer脚本的例子可以在SteamVR_Unity_Toolkit/Examples/003_Controller_SimplePointer场景中看到并且事件用法和监听的脚本例子可以看SteamVR_Unity_Toolkit/Examples/Resources/Scripts/VRTK_ControllerPointerEvents_ListenerExample.cs脚本。


Bezier Curve Laser Pointer (VRTK_BezierPointer)贝塞尔曲线激光指针(VRTK_BezierPointer)
The Bezier Pointer emits a curved line (made out of game objects) from the end of the controller to a point on a ground surface (at any height). It is more useful than the Simple Laser Pointer for traversing objects of various heights as the end point can be curved on top of objects that are not visible to the player.

贝塞尔指针从控制器末端发出一个曲线(由游戏对象组构而成)到(任何高度的)地面上一点。这比简单激光指针要有用的多,因为终点能够弯曲到玩家看不见的对象顶部,所以就可以传送到各种高度的对象上。

The laser beam is activated by default by pressing the Grip on the controller. The event it is listening for is the AliasPointerevents so the pointer toggle button can be set by changing the Pointer Toggle button on the VRTK_ControllerEvents script parameters.


激光束默认按控制器上的抓握键Grip来激活。事件侦听AliasPointer别名事件,所以Pointer Toggle button可以通过在VRTK_ControllerEvents 脚本中改变Pointer Toggle button来进行选择设置。


The Bezier Pointer script is attached to a Controller object within the [CameraRig] prefab and the Controller object also requires the VRTK_ControllerEvents script to be attached as it uses this for listening to the controller button events for enabling and disabling the beam.

贝塞尔指针脚本被添加到[CameraRig]预制里的控制器对象上,控制器对象同时需要添加VRTK_ControllerEvents脚本用来监听控制器按钮开关光束的事件。

The following script parameters are available:
可用脚本参数如下:

· Enable Teleport: If this is checked then the teleport flag is set to true in the Destination Set event so teleport scripts will know whether to action the new destination. This allows controller beams to be enabled on a controller but never trigger a teleport (if this option is unchecked).
· Pointer Hit Color: The colour of the beam when it is colliding with a valid target. It can be set to a different colour for each controller.
· Pointer Miss Color: The colour of the beam when it is not hitting a valid target. It can be set to a different colour for each controller.
· Show Play Area Cursor: If this is enabled then the play area boundaries are displayed at the tip of the pointer beam in the current pointer colour.
· Play Area Cursor Dimensions: Determines the size of the play area cursor and collider. If the values are left as zero then the Play Area Cursor will be sized to the calibrated Play Area space.
· Handle Play Area Cursor Collisions: If this is ticked then if the play area cursor is colliding with any other object then the pointer colour will change to the Pointer Miss Color and the WorldPointerDestinationSet event will not be triggered, which will prevent teleporting into areas where the play area will collide.
· Beam Always On: If this is checked the the pointer beam is always visible but the Destination Set event is still only emitted when the assigned button is pressed.
· Activate Delay: The time in seconds to delay the pointer beam being able to be active again. Useful for preventing constant teleportation.
· Pointer Length: The length of the projected forward pointer beam, this is basically the distance able to point from the controller potiion.
· Pointer Density: The number of items to render in the beam bezier curve. A high number here will most likely have a negative impact of game performance due to large number of rendered objects.
· Show Pointer Cursor: A cursor is displayed on the ground at the location the beam ends at, it is useful to see what height the beam end location is, however it can be turned off by toggling this.
· Pointer Cursor Radius: The size of the ground pointer cursor, This number also affects the size of the objects in the bezier curve beam. The larger the raduis, the larger the objects will be.
· Beam Curve Offset: The amount of height offset to apply to the projected beam to generate a smoother curve even when the beam is pointing straight.
· Custom Pointer Tracer: A custom Game Object can be applied here to use instead of the default sphere for the beam tracer. The custom Game Object will match the rotation of the controller.
· Custom Pointer Cursor: A custom Game Object can be applied here to use instead of the default flat cylinder for the pointer cursor.

· Enable Teleport(启用传送):如果勾选了,在目标设置事件中的teleport标志位就设为true,所以传送脚本就知道是否要行动到新的目标。如果这个选项没有勾选的话,控制器光束启动但是不会触发位移。

· Point Hit Color(指针碰撞颜色):当光束和一个有效目标碰撞的颜色。每个控制器可以有不同的颜色设置。

· Pointer Miss Color(指针无碰撞颜色):当光束没有命中有效目标时的颜色。每个控制器可以有不同的颜色设置。

· Show Play Area Cursor(显示游玩区光标):如果这个启动,游玩区界限就会在光束指针的顶端显示出来,颜色和当前指针颜色相同。

· Play Area Cursor Dimensions(游玩去光标尺寸):决定游玩区光标和碰撞的尺寸。如果值为零,Play Area Cursor 的尺寸将根据Play Area空间进行校正。

· Handle Play Area Cursor Collisions(处理游玩区光标碰撞):如果勾选,当游玩区光标和其他物体发生碰撞时,指针颜色就会变成Pointer Miss Color的颜色且WorldPointerDestinationSet 事件将不会被触发,这将防止传送到游玩区会发生碰撞的区域。

· Beam Always On(光束总是开启):如果这个勾选,光束指针总是可见,但是设置目标点事件仍然只会在所指定按钮松开时发出。

· Activate Delay(激活间隔):能够再次激活指针光束的延迟时间秒数。用来防止持续传送。

· Pointer Length(指针光束长度):在停止前光束投射的距离。

· Pointer Density(指针密度):贝塞尔曲线光束渲染的物体个数。这里数值太高将很可能会因为大量渲染对象来对游戏性能有负面影响。

· Show Pointer Cursor显示指针光标:在光束终点位置的地面显示光标。用来看光束终点位置的高度很有用,它可以通过切换这个来关闭。

· Pointer Cursor Radius(指针光标半径):地面指针光标的尺寸,这个值也会影响贝塞尔曲线光束里的对象的尺寸。半径越大,对象尺寸越大。


· Beam Curve Offset光束曲线偏移: 投射光束时应用的高度偏移量,就算在光束径直指向时也能产生一个光滑的曲线。

· Custom Pointer Tracer自定义指针轨迹: 可以在这里设置一个自定义的游戏对象用来代替光束轨迹的默认球体。自定义游戏对象将和控制器的旋转想匹配。

· Custom Pointer Cursor自定义指针光标):  可以在这里设置一个自定义的游戏对象用来代替指针光标的默认平柱体。

The Bezier Pointer object extends the VRTK_WorldPointer abstract class and therefore emits the same events and payload.

贝塞尔指针对象扩展自VRTK_WorldPointer 抽象类并因此发出相同的事件和有效数据。


An example of the VRTK_BezierPointer script can be viewed in the sceneSteamVR_Unity_Toolkit/Examples/009_Controller_BezierPointer which is used in conjunction with the Height Adjust Teleporter shows how it is possible to traverse different height objects using the curved pointer without needing to see the top of the object.

VRTK_BezierPointer脚本的例子参见SteamVR_Unity_Toolkit/Examples/009_Controller_BezierPointer场景,它被连同Height Adjust Teleporter脚本一起使用,来显示怎样可以不需要看到对象的顶部就能使用曲线指针来传送到不同高度的对象上。


Another example can be viewed in the scene SteamVR_Unity_Toolkit/Examples/012_Controller_PointerWithAreaCollisionthat shows how a Bezier Pointer with the Play Area Cursor and Collision Detection enabled can be used to traverse a game area but not allow teleporting into areas where the walls or other objects would fall into the play area space enabling the player to enter walls.

另一个例子可以参见SteamVR_Unity_Toolkit/Examples/012_Controller_PointerWithAreaCollision场景,这里演示了一个开启了游玩区光标和碰撞检测的贝塞尔指针怎样被用来穿过游戏区域,但是不允许传送到墙壁或者其他对象的区域而导致游玩区让玩家穿进墙壁。


The bezier curve generation code is in another script located at SteamVR_Unity_Toolkit/Scripts/Helper/CurveGenerator.csand was heavily inspired by the tutorial and code from Catlike Coding.

贝塞尔曲线生成的代码是另一脚本,位置在SteamVR_Unity_Toolkit/Scripts/Helper/CurveGenerator.cs,这基本是受Catlike Coding的教程和代码的启发(http://catlikecoding.com/unity/tutorials/curves-and-splines/)。




Basic Teleporter (VRTK_BasicTeleport)基础传送器(VRTK_BasicTeleport)

The basic teleporter updates the [CameraRig] x/z position in the game world to the position of a World Pointer's tip location which is set via the WorldPointerDestinationSet event. The y position is never altered so the basic teleporter cannot be used to move up and down game objects as it only allows for travel across a flat plane.

基础传送器更新[CameraRig]在游戏世界中的x和z位置到由WorldPointerDestinationSet事件设置定位的世界指针顶端的位置。y位置从不改变,所以基础传送器不能用来上下移动游戏对象而只能水平移动。

The Basic Teleport script is attached to the [CameraRig] prefab and requires an implementation of the WorldPointer script to be attached to another game object (e.g. VRTK_SimplePointer attached to the Controller object).

基础传送器脚本被添加到[CameraRig] 预制下面并需要一个实现了WorldPointer 的脚本添加到另一个游戏对象上(如VRTK_SimplePointer添加到控制器对象上)。


The following script parameters are available:
可用脚本参数如下:

· Blink Transition Speed: The fade blink speed can be changed on the basic teleport script to provide a customised teleport experience. Setting the speed to 0 will mean no fade blink effect is present. The fade is achieved via the SteamVR_Fade.csscript in the SteamVR Unity Plugin scripts.
· Distance Blink Delay: A range between 0 and 32 that determines how long the blink transition will stay blacked out depending on the distance being teleported. A value of 0 will not delay the teleport blink effect over any distance, a value of 32 will delay the teleport blink fade in even when the distance teleported is very close to the original position. This can be used to simulate time taking longer to pass the further a user teleports. A value of 16 provides a decent basis to simulate this to the user.
· Headset Position Compensation: If this is checked then the teleported location will be the position of the headset within the play area. If it is unchecked then the teleported location will always be the centre of the play area even if the headset position is not in the centre of the play area.
· Ignore Target With Tag Or Class: A string that specifies an object Tag or the name of a Script attached to an obejct and notifies the teleporter that the destination is to be ignored so the user cannot teleport to that location. It also ensure the pointer colour is set to the miss colour.

· Blink Transition Speed眨眼淡入淡出速度:可以在基础传送脚本中改变眨眼渐变速度来提供一个自定义的传送体验。速度设置为0意味着没有渐变眨眼特效呈现。渐变通过 SteamVR Unity 插件脚本里的SteamVR_Fade.cs脚本实现。

· Distance Blink Delay距离眨眼延时: 范围从0到32,这个值决定了基于被传送距离的眨眼过渡保持黑屏的时长。值为0时,任何传送距离都不会延长传送的眨眼过渡,值为32时,就算距离初始点很近的被传送距离都会延长传送的眨眼过渡。这可以被用来模拟用户传送更远的距离花费更长时间。值为16对用户来说就刚好。

· Headset Position Compensation(头盔位置补偿): 如果勾选,传送坐标将会式游玩区内头盔的位置。如果没有勾选,传送坐标将总是游玩区中间的位置,就算头盔位置不在游玩区中间也式如此。

· Ignore Target With Tag Or Class(忽略带有标签或脚本的目标): 一个指定对象标签或者对象上添加的脚本名字的字符串,通知传送器这种目标点应该被忽略,所以用户就不能传送到这些位置上。同时也确保指针颜色被设为丢失目标点颜色。

An example of the VRTK_BasicTeleport script can be viewed in the sceneSteamVR_Unity_Toolkit/Examples/004_CameraRig_BasicTeleport. The scene uses the VRTK_SimplePointer script on the Controllers to initiate a laser pointer with the Controller Grip button and when the laser pointer is deactivated (release theGrip) then the player is teleported to the location of the laser pointer tip.

VRTK_BasicTeleport 脚本的例子可以参见SteamVR_Unity_Toolkit/Examples/004_CameraRig_BasicTeleport场景。这个场景使用控制器上的VRTK_SimplePointer 脚本在按下grip按钮时初始化一个激光指针,松开Grip按钮时激光指针失效,然后玩家传送到激光指针顶端位置。


Height Adjustable Teleporter (VRTK_HeightAdjustTeleport)可调节高度的传送器(VRTK_HeightAdjustTeleport)

The height adjust teleporter extends the basic teleporter and allows for the y position of the [CameraRig] to be altered based on whether the teleport location is on top of another object.


高度调整传送器继承自基础传送器,它允许根据传送位置是否在其他对象顶部来让[CameraRig]改变y位置。


Like the basic teleporter the Height Adjust Teleport script is attached to the [CameraRig] prefab and requires a World Pointer to be available.


和基础传送器一样,高度调整传送器被添加到[CameraRig]预制并需要一个可用的世界指针。


The following script parameters are available:
可用脚本参数如下:


· Blink Transition Speed: The fade blink speed on teleport.
· Distance Blink Delay: A range between 0 and 32 that determines how long the blink transition will stay blacked out depending on the distance being teleported. A value of 0 will not delay the teleport blink effect over any distance, a value of 32 will delay the teleport blink fade in even when the distance teleported is very close to the original position. This can be used to simulate time taking longer to pass the further a user teleports. A value of 16 provides a decent basis to simulate this to the user.
· Headset Position Compensation: If this is checked then the teleported location will be the position of the headset within the play area. If it is unchecked then the teleported location will always be the centre of the play area even if the headset position is not in the centre of the play area.
· Ignore Target With Tag Or Class: A string that specifies an object Tag or the name of a Script attached to an obejct and notifies the teleporter that the destination is to be ignored so the user cannot teleport to that location. It also ensure the pointer colour is set to the miss colour.
· Play Space Falling: Checks if the player steps off an object into a part of their play area that is not on the object then they are automatically teleported down to the nearest floor.


· Blink Transition Speed 眨眼淡入淡出速度 :可以在基础传送脚本中改变眨眼渐变速度来提供一个自定义的传送体验。速度设置为0意味着没有渐变眨眼特效呈现。渐变通过 SteamVR Unity 插件脚本里的SteamVR_Fade.cs脚本实现。


· Distance Blink Delay 距离眨眼延时 : 范围从0到32,这个值决定了基于被传送距离的眨眼过渡保持黑屏的时长。值为0时,任何传送距离都不会延长传送的眨眼过渡,值为32时,就算距离初始点很近的被传送距离都会延长传送的眨眼过渡。这可以被用来模拟用户传送更远的距离花费更长时间。值为16对用户来说就刚好。


· Headset Position Compensation (头盔位置补偿) : 如果勾选,传送坐标将会式游玩区内头盔的位置。如果没有勾选,传送坐标将总是游玩区中间的位置,就算头盔位置不在游玩区中间也式如此。


· Ignore Target With Tag Or Class (忽略带有标签或脚本的目标) : 一个指定对象标签或者对象上添加的脚本名字的字符串,通知传送器这种目标点应该被忽略,所以用户就不能传送到这些位置上。同时也确保指针颜色被设为丢失目标点颜色。


· Play Space Falling 游玩区坠落 ):检查是否玩家是否走出对象,即所在游玩区的位置不在对象上,然后就会自动传送到最近的地面上。


The Play Space Falling option also works in the opposite way that if the player's headset is above an object then the player is teleported automatically on top of that object, which is useful for simulating climbing stairs without needing to use the pointer beam location. If this option is turned off then the player can hover in mid air at the same y position of the object they are standing on.


反过来说Play Space Falling 选项是在玩家头盔在一个对象上方时会自动传送到一个对象的顶部,这一点在模拟爬梯子时很有用,不需要使用指针光束定位。如果这个选项关闭,玩家就能在他们所站在的对象的同样y高度的空中行走(也就是有一部分游玩区在对象外部)。


An example of the VRTK_HeightAdjustTeleport script can be viewed in the sceneSteamVR_Unity_Toolkit/Examples/007_CameraRig_HeightAdjustTeleport. The scene has a collection of varying height objects that the player can either walk up and down or use the laser pointer to climb on top of them.


VRTK_HeightAdjustTeleport 脚本的例子参见SteamVR_Unity_Toolkit/Examples/007_CameraRig_HeightAdjustTeleport场景。场景有许多不同高度对象,玩家可在来回走或者使用激光束爬到它们顶部。


Another example can be viewed in the scene SteamVR_Unity_Toolkit/Examples/010_CameraRig_TerrainTeleporting which shows how the teleportation of a player can also traverse terrain colliders.
Another example can be viewed in the scene SteamVR_Unity_Toolkit/Examples/020_CameraRig_MeshTeleporting which shows how the teleportation of a player can also traverse mesh colliders.


另一个例子参见SteamVR_Unity_Toolkit/Examples/010_CameraRig_TerrainTeleporting场景,展示了玩家也能够在地形碰撞器上传送。还有个例子在 SteamVR_Unity_Toolkit/Examples/020_CameraRig_MeshTeleporting场景中,显示玩家在网格碰撞器上传送。




Fading On Headset Collision (VRTK_HeadsetCollisionFade) 头盔碰撞淡出(VRTK_HeadsetCollisionFade)
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 player putting their head into a game object and seeing the inside of the object clipping, which is an undesired effect.

头盔碰撞淡出的目的是为了检测用户的VR头盔何时碰撞到其他游戏对象并淡出屏幕到一个单色。这是为了处理玩家把头放进一个游戏对象里看到对象内部的裁剪,这不是我们所期望的。

The reasoning behind this is if the player puts their head where it shouldn't be, then fading to a colour (e.g. black) will make the player 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.

如果头盔正在碰撞,那么传送行为就被禁用来防止穿插穿墙的作弊。

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

使用Unity 5.3及之前版本,头盔碰撞淡出脚本添加到[CameraRig] 预制的Camera(head)对象上。

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.

使用Unity 5.4及之后版本,头盔碰撞淡出脚本添加到[CameraRig] 预制下的Camera (head)里的Camera(eye)对象上。


The following script parameters are available:
可用脚本参数如下:

· Blink Transition Speed: The fade blink speed on collision.
· Fade Color: The colour to fade the headset to on collision.

· Blink Transition Speed 眨眼淡入淡出速度 :碰撞时淡入淡出速度。

· Fade Color 淡出颜色 :头盔碰撞时淡出颜色。

The following events are emitted:
发出事件如下:

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

· HeadsetCollisionDetect: 当用户头盔碰到其他游戏对象时发出。

· HeadsetCollisionEnded:当用户头盔停止碰撞游戏对象时发出。

The event payload that is emitted contains:
发出事件的有效载体内容包括:

· collider: The Collider of the game object the headset has collided with.
· currentTransform: The current Transform of the object that the Headset Collision Fade script is attached to (Camera).

· collider: 头盔所碰撞的游戏对象的碰撞器。

· currentTransform: 当前头盔碰撞淡入淡出脚本所添加到的对象(相机)的Transform。

An example of the VRTK_HeadsetCollisionFade script can be viewed in the sceneSteamVR_Unity_Toolkit/Examples/011_Camera_HeadSetCollisionFading. The scene has collidable walls around the play area and if the player puts their head into any of the walls then the headset will fade to black.

VRTK_HeadsetCollisionFade 脚本例子参见SteamVR_Unity_Toolkit/Examples/011_Camera_HeadSetCollisionFading场景。场景在游玩区周围有可碰撞的墙壁,如果玩家把头放进墙壁,头盔就将渐变成黑色。



Player Presence (VRTK_PlayerPresence) 玩家呈现(VRTK_PlayerPresence)
The concept that the VR user has a physical in game presence which is accomplished by adding a collider and a rigidbody at the position the user is standing within their play area. This physical collider and rigidbody will prevent the user from ever being able to walk through walls or intersect other collidable objects. The height of the collider is determined by the height the user has the headset at, so if the user crouches then the collider shrinks with them, meaning it's possible to crouch and crawl under low ceilings.

VR用户在游戏呈现中有身体这一概念,它通过在用户站立在游玩区中的位置添加碰撞和刚体来实现。身体的碰撞和刚体将防止用户能狗穿过墙壁或者和其他可碰撞对象穿插。碰撞体的高度由用户头盔所在高度决定,如果用户下蹲,碰撞体同样收缩,这意味着可能在低的空间去下蹲和爬行通过。

The following script parameters are available:
可用脚本参数如下:

· Headset Y Offset:The box collider which is created for the user is set at a height from the user's headset position. If the collider is required to be lower to allow for room between the play area collider and the headset then this offset value will shorten the height of the generated box collider.
· Ignore Grabbed Collisions:If this is checked then any items that are grabbed with the controller will not collide with the box collider and rigid body on the play area. This is very useful if the user is required to grab and wield objects because if the collider was active they would bounce off the play area collider.

· Headset Y Offset 头盔y偏移 : 为用户创建的盒型碰撞体的高度由用户头盔位置设置。如果需要碰撞体小一点来让游玩区和头盔之间留有空间的话,这个值将降低生成的盒型碰撞体的高度。

· Ignore Grabbed Collisions 忽略抓取碰撞 : 如果勾选,任何被控制器抓取的物品都不会和游玩区的盒碰撞体及刚体发生碰撞。这在用户需要抓取和挥动对象时是很有用的,因为如果碰撞体激活,这些抓取的东西就会被游玩区的碰撞体弹开。

An example of theVRTK_PlayerPresencescript can be viewed in the sceneSteamVR_Unity_Toolkit/Examples/017_CameraRig_TouchpadWalking. The scene has a collection of walls and slopes that can be traversed by the user with the touchpad but the user cannot pass through the objects as they are collidable and the rigidbody physics won't allow the intersection to occur.

VRTK_PlayerPresence 脚本例子可参见SteamVR_Unity_Toolkit/Examples/017_CameraRig_TouchpadWalking场景。场景有很多墙体和斜坡,用户可以用触摸板来四处行走,但是不能穿过这些对象,因为它们是可碰撞的并且刚体物理将不允许发生穿叉。


Touchpad Movement (VRTK_TouchpadWalking) 触摸板移动 (VRTK_TouchpadWalking)
The ability to move the play area around the game world by sliding a finger over the touchpad is achieved using this script. The Touchpad Walking script is applied to the[CameraRig]prefab and adds a rigidbody and a box collider to the user's position to prevent them from walking through other collidable game objects.

通过手指在触摸板上滑动来实现用这个脚本让游玩区在游戏世界中能够移动。TouchpadWalking脚本用在[CameraRig]预制上,并且在用户位置添加一个刚体和盒型碰撞来防止他们穿过其他带碰撞的游戏对象。

If the Headset Collision Fade script has been applied to the Camera prefab, then if a user attempts to collide with an object then their position is reset to the last good known position. This can happen if the user is moving through a section where they need to crouch and then they stand up and collide with the ceiling. Rather than allow a user to do this and cause collision resolution issues it is better to just move them back to a valid location. This does break immersion but the user is doing something that isn't natural.

如果Headset Collision Fade脚本已经被添加到相机预制上,如果用户试着和一个对象发生碰撞,那么他的位置就会被重置为最近的正常的位置。这可能发生在用户穿过需要躬身的区域中途站了起来和顶部发生了碰撞。与其允许用户这样做而引起碰撞 问题,倒不如直接移动回到一个正常的位置。这确实破坏了沉浸感,但用户正在做的事情也是不自然的。

The following script parameters are available:
可用脚本参数如下:

· Left Controller:If this is checked then the left controller touchpad will be enabled to move the play area. It can also be toggled at runtime.
· Right Controller:If this is checked then the right controller touchpad will be enabled to move the play area. It can also be toggled at runtime.
· Max Walk Speed:The maximum speed the play area will be moved when the touchpad is being touched at the extremes of the axis. If a lower part of the touchpad axis is touched (nearer the centre) then the walk speed is slower.
· Deceleration:The speed in which the play area slows down to a complete stop when the user is no longer touching the touchpad. This deceleration effect can ease any motion sickness that may be suffered.

· Left Controller: 如果勾选,左控制器的触摸板就能移动游玩区。在运行时可以被切换。

· Right Controller: 如果勾选,右控制器的触摸板就能移动游玩区。在运行时可以被切换。

· Max Walk Speed 当触摸板被触摸到轴的极限时游玩区所能达到的最大移动速度。触摸板距离中心越近的位置被触摸,移动速度就越慢。

· Deceleration 减速度 ): 当用户不再触摸到触摸板时游玩区从减速到完全停止的速度。这种减速度效果可以减缓可能遭受的移动恶心。

An example of theVRTK_TouchpadWalkingscript can be viewed in the sceneSteamVR_Unity_Toolkit/Examples/017_CameraRig_TouchpadWalking. The scene has a collection of walls and slopes that can be traversed by the user with the touchpad. There is also an area that can only be traversed if the user is crouching. Standing up in this crouched area will cause the user to appear back at their last good known position.

VRTK_TouchpadWalking 脚本的例子参见SteamVR_Unity_Toolkit/Examples/017_CameraRig_TouchpadWalking场景。场景中有很多墙壁和梯子,用户可以用触摸板来移动。还有个区域只有用户蹲下才能穿过。在俯身区域挺起身体将导致用户闪回他们最近的正常位置。

VRTK_RoomExtender游玩区空间扩展
This script allows the playArea to move with the player. The CameraRig is only moved when at the edge of a defined circle. Aims to create a virtually bigger play area. I have added a demo scene to test the script (028_CameraRig_RoomExtender).

这个脚本允许游玩区跟随玩家移动。CameraRig 只在达到定义的圈的边缘才会移动。目的是为了创造一个虚拟的更大的游玩区。测试这个脚本的demo场景为028_CameraRig_RoomExtender。

To use this add this script to the CameraRig.
把脚本添加到CameraRig来使用。

The following script parameters are available:
可用脚本参数如下:

· Additional Movement Multiplier:This is the factor by which movement at the edge of the circle is amplified. 0 is no movement of the CameraRig. Higher values simulate a bigger play area but may be to uncomfortable.
· Head Zone Radius:This is the size of the circle in which the playArea is not moved and everything is normal. If it is to low it becomes uncomfortable when crouching.
· Debug Transform:This transform visualises the circle around the player where the CameraRig is not moved. In the demo scene this is a cylinder at floor level. Remember to turn of collisions.

· Additional Movement Multiplier 额外移动乘数 : 圈边缘的移动放大因数。 0 就是不移动CameraRig。值越高模拟的游玩区域就越大,但是也可能就越不令人舒适。

· Head Zone Radius 头部空间半径 : 游玩区不会发生移动的圆圈尺寸,一切都正常的。 如果值太低,在蹲下时就会感到不舒服

· Debug Transform 调试 Transform : 这个 transform 让玩家周围的 CameraRig 不移动圆圈显示出来。在 demo 场景里就是一个在地板上的柱体。记得关闭碰撞。

 

转载于:https://www.cnblogs.com/macky/p/9083702.html


http://www.ppmy.cn/news/424377.html

相关文章

《论工业社会及其未来》—泰德.卡辛斯基

中文译文基于1996年中国文史出版社《轰炸文明——发往人类未来的死亡通知单》,原译者王小东 INTRODUCTION 介绍 1. The Industrial Revolution and itsconsequences have been a disaster for the human race. They have greatlyincreased the life-expectancy of those of us…

大学英语综合教程四 Unit 1至Unit 8 课文内容英译中 中英翻译

大学英语综合教程四 Unit 1至Unit 8 课文内容英译中 中英翻译 大家好,我叫亓官劼(q guān ji ),在CSDN中记录学习的点滴历程,时光荏苒,未来可期,加油~博客地址为:亓官劼的博客 本文原…

[翻译]《Programming - Principles and Practice Using C++, Second Edition》- Chapter 1

本文导航(全文25000字左右,按正常阅读速度,大概需要50-70分钟) Computers, People, and Programming 计算机,人和编程1.1 Introduction 介绍1.2 Software 软件1.3 People 人1.4 Computer Science 计算机科学1.5.1 Scre…

【雅思口语】安娜口语学习记录 Part2

第二部分:主题卡片陈述 在这一部分,考官会递给考生一张主题卡片,卡片上附有问题和相关观点。拿到卡片后,考生有一分钟时间准备,同时可以在提供的草纸上作笔记(不可以拿出考场)。 然后,考生应该就所给的话题…

苹果真伪查询_苹果自研M1芯片Mac电脑开启预售!该不该冲?

原标题:苹果自研M1芯片Mac电脑开启预售!该不该冲? 昨天凌晨是苹果今年的最后一次新品发布会,苹果在发布会上给大家展示了三款新Mac电脑,其中包括13英寸的新MacBook Air、13寸的新MacBook Pro以及全新的Mac mini。这三款…

正式发售超两周 iPhone7部分机型仍然缺货

2016年的中国手机市场风云变幻,以往的霸主苹果和三星已经跌落神坛,一个想依靠新机iPhone 7夺回市场,一个则尚未从Note 7爆炸事件中恢复;华为、OPPO、Vivo等国产品牌则大踏步前进,挤占了销量排行榜的前列;一…

苹果mp3软件_神技能!!!音视频制作软件

深处在短视频爆炸的时代,怎么能不学点音视频技能呢? 下面这些技能必须get起来!!!! 音频 1、朗读女 推荐原因:免费、合成mp3或wav格式、可设置/下载网络发音人、音速、音调、可以段落分不同发音人…

外媒:苹果自动驾驶裁员表明其AI战略发生巨变

https://www.toutiao.com/a6651062420649280003/ 2019-01-27 14:39:04 [摘要]虽然自动驾驶汽车技术可能仍是苹果的一项重要计划。但从字里行间看,苹果可能在收缩自动驾驶研发项目,加强一般性人工智能的研发队伍。 腾讯科技讯 近日,苹果公司对…

“爆炸门”苹果补刀,三星该“哭晕了”!

【阅读原文】 10月12日起至18日,2016年全国大众创业万众创新活动周在深圳举行,第二届深圳国际创客周也同期开幕,合称“全国双创周”。 此次全球创客齐聚深圳,其发言人选的豪华阵容也是相当的惊人!发言人名单如下&#…

苹果xr如何关机_苹果笔记本被禁止上飞机!存在燃烧爆炸风险

责任编辑:XC丨插图来自于网络 MacBook Pro禁止上飞机 大家都知道早在之前三星就被闹出沸沸扬扬的爆炸门,当年三星的Note7被人称为移动的微型炸弹。 三星Note7由于存在 着火爆炸 的隐患,一度被禁止上飞机,这也是罕有的数码产品受飞行禁令的设…

荣耀8青春版android,华为荣耀8青春版有几个版本?荣耀8青春版低配版/标准版/高配版区别对比评测...

华为荣耀8青春版有几个版本?2月21日下午,荣耀在北京召开新品发布会,正式发布了荣耀8青春版智能手机。而细心的朋友会发现,荣耀8青春版在外观设计方面基本上和荣耀8保持一致,双面2.5D玻璃非常显眼。那么荣耀8青春版有几…

荣耀v8鸿蒙,荣耀8和荣耀V8对比评测:看完这篇就不用纠结买谁

当硬件、品质以及用户体验做到一定程度,变得已经相对完善。那么,外观设计就会成为打动用户的关键因素。毕竟消费者的诉求不仅仅是配置和质量,还包括外观和品牌等因素。荣耀8就是根据这种思路研发的产品,在荣耀良好的硬件和品质的基…

emui 4.1 基于android 6.0,【荣耀V8评测】基于Android 6.0的EMUI 4.1_荣耀 V8_手机评测-中关村在线...

荣耀V8搭载了基于Android 6.0的EMUI 4.1,对于这个版本大家应该都不算陌生,因为在此也有机型采用了同样版本的UI。这本身不是一个非常大的版本演进,但是在一些细微功能上还是值得挑出来聊一聊的。 搭载基于Android 6.0的EMUI 4.1 可调节屏幕色温,开启护眼模式减少蓝光 在设置…

android 8 荣耀9,华为荣耀9和荣耀8哪个好_荣耀8和荣耀9区别-太平洋IT百科

荣耀9于6月在上海发布,大家都知道这款手机主打高颜值、双摄像头拍照、曲面玻璃等特性,售价2299元起。华为荣耀9和荣耀8哪个好?荣耀8和荣耀9区别?接下来本文带来荣耀9和荣耀8区别对比详细评测。 华为荣耀9和荣耀8哪个好?荣耀8和荣耀9区别? 华为荣耀9配…

第13章_事务基础知识

第13章_事务基础知识 1.数据库事务概述 事务是数据库区别于文件系统的重要特性之一,当我们有了事务就会让数据库始终保持一致性,同时我们还能通过事务的机制恢复到某个时间点,这样可以保证已提交到数据库的修改不会因为系统崩溃而丢失。 1…

如何在 Vue3 组件中使用 TS 类型(必看)

一、为 props 标注类型 使用 <script setup> 方式一&#xff1a;当使用 <script setup> 时&#xff0c;defineProps() 宏函数支持从它的参数中推导类型&#xff1a; const props defineProps({treeTableProps: {type: Array,default: null,required: false},ms…

【C++】红黑树的概念与模拟实现

红黑树的概念与模拟实现 红黑树的概念红黑树的性质红黑树节点的定义红黑树的迭代器红黑树的插入红黑树和AVL树的比较红黑树的模拟实现 红黑树的概念 红黑树&#xff0c;是一种二叉搜索树&#xff0c;但在每个结点上增加一个存储位表示结点的颜色&#xff0c;可以是Red或Black。…

CLION开发STM32之W5500系列(一)

开篇说明 本系列适用于需要使单片机通过网口进行通信的开发。针对的是刚入门的同学们,也是个人的经验分享。本次使用到的芯片为stm32f103vet6(其他的也可以)本次使用的网口模块为W5500,其网关有示例程序均可以参考.本次使用Clion+OpenOCD+ARM-GCC 进行开发、烧录、编译.建议熟…

移动DICT项目是什么?

DICT项目 我们运营商的伙伴&#xff0c;很多人都知道我们的DICT&#xff0c;但是大家知不知道什么是DICT。你想一想&#xff0c;所谓的DICT&#xff0c;就是指的大数据技术与IT和CT的深度融合。 实际上&#xff0c;DICT的可以拆分成三个词&#xff0c; 第一个DT&#xff0c…

mysqldump 数据备份

使用实例 使用方法 Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3…] OR mysqldump [OPTIONS] --all-databases [OPTIONS] For more options, use mysqldump --help OPTION通常是&#xff1a;-u 用户名 -p …
最新文章