SW 중심대학 OSS GIT 서버
새로운 리포
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.XR.Interaction.Toolkit;
public class LocomotionController : MonoBehaviour{ public XRController leftTeleportRay; public XRController rightTeleportRay; public InputHelpers.Button teleportActivationButton; //텔레포트 활성화 버튼
public float activationThreshold = 0.1f; //살짝만 누르면 텔레포트 활성화 되도록
//각 손의 텔레포트 활성화 할것인가? => UnityEvent 에서 설정
public bool EnableLeftTeleport { get; set; } = true; public bool EnableRightTeleport { get; set; } = true;
public XRRayInteractor leftRayInteractor; public XRRayInteractor rightRayInteractor;
// Update is called once per frame
void Update() { //각 컨트롤러의 텔레포트를 활성화/비활성화
if (leftTeleportRay) { //InteractorRay가 무엇에 닿았는가?
bool isLeftInteractorRayHovering = leftRayInteractor.TryGetHitInfo(out Vector3 pos, out Vector3 norm, out int posInLine, out bool isValid); leftTeleportRay.gameObject.SetActive(CheckIfActivated(leftTeleportRay) && EnableLeftTeleport && !isLeftInteractorRayHovering); }
if (rightTeleportRay) { bool isRightInteractorRayHovering = rightRayInteractor.TryGetHitInfo(out Vector3 pos, out Vector3 norm, out int posInLine, out bool isValid); rightTeleportRay.gameObject.SetActive(CheckIfActivated(rightTeleportRay) && EnableRightTeleport && !isRightInteractorRayHovering); } }
//특정 컨트롤러의 특정 버튼이 눌렀는가? 를 리턴하는 함수
public bool CheckIfActivated(XRController controller) { //controller의 활성화 버튼을 activationThreshold 이상으로 눌렀으면, 그 값을 저장하고 리턴
InputHelpers.IsPressed(controller.inputDevice, teleportActivationButton, out bool isActivated, activationThreshold);
return isActivated; }}
|