码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2018-05-24 18:23:41      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:ams   class   应该   lib   oppo   ext   rally   ping   rem   

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场景里就是一个在地板上的柱体。记得关闭碰撞。

 

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

标签:ams   class   应该   lib   oppo   ext   rally   ping   rem   

原文地址:https://www.cnblogs.com/macky/p/9083702.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!