123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using VRTK;
- public class RockerMove_VRTK : RockerMove
- {
- //平面移动
- [Header("仅XZ轴平面移动")]
- public bool planarMovement = false;
- //移动按键
- public SDK_BaseController.ButtonTypes moveBtn;
- //移动控制器
- public SDK_BaseController.ControllerHand moveHand = SDK_BaseController.ControllerHand.Right;
- public override void Update()
- {
- base.Update();
- VRTK_ControllerReference _controllerReference = VRTK_DeviceFinder.GetControllerReferenceRightHand();
- if (VRTK_SDK_Bridge.GetControllerButtonState(moveBtn, SDK_BaseController.ButtonPressTypes.PressDown
- , _controllerReference))
- {
- InitRockerPoint(_controllerReference.model.transform);
- }
- else if (VRTK_SDK_Bridge.GetControllerButtonState(moveBtn, SDK_BaseController.ButtonPressTypes.PressUp
- , _controllerReference))
- {
- Close();
- }
- }
- /// <summary>
- /// 移动方式
- /// </summary>
- public override void Move()
- {
- Vector3 _moveDir = holdPoint.position - rockerPoint.position;
- if (planarMovement)
- {
- _moveDir = new Vector3(_moveDir.x, 0, _moveDir.z);
- }
- cameraRig.transform.Translate(_moveDir * moveSpeed * Time.deltaTime, Space.World);
- }
- }
|