https://assetstore.unity.com/packages/3d/environments/simplepoly-city-low-poly-assets-58899
SimplePoly City - Low Poly Assets | 3D 주변환경 | Unity Asset Store
Elevate your workflow with the SimplePoly City - Low Poly Assets asset from VenCreations. Find this & other 주변환경 options on the Unity Asset Store.
assetstore.unity.com
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
public class SimpleCapsuleWithStickMovement : MonoBehaviour
{
public bool EnableLinearMovement = true;
public bool EnableRotation = true;
public bool HMDRotatesPlayer = true;
public bool RotationEitherThumbstick = false;
public float RotationAngle = 45.0f;
public float Speed = 0.0f;
public OVRCameraRig CameraRig;
private bool ReadyToSnapTurn;
private Rigidbody _rigidbody;
public event Action CameraUpdated;
public event Action PreCharacterMove;
private void Awake()
{
_rigidbody = GetComponent<Rigidbody>();
if (CameraRig == null) CameraRig = GetComponentInChildren<OVRCameraRig>();
}
void Start()
{
}
private void FixedUpdate()
{
if (CameraUpdated != null) CameraUpdated();
if (PreCharacterMove != null) PreCharacterMove();
if (HMDRotatesPlayer) RotatePlayerToHMD();
if (EnableLinearMovement) StickMovement();
if (EnableRotation) SnapTurn();
}
void RotatePlayerToHMD()
{
Transform root = CameraRig.trackingSpace;
Transform centerEye = CameraRig.centerEyeAnchor;
Vector3 prevPos = root.position;
Quaternion prevRot = root.rotation;
transform.rotation = Quaternion.Euler(0.0f, centerEye.rotation.eulerAngles.y, 0.0f);
root.position = prevPos;
root.rotation = prevRot;
}
void StickMovement()
{
Quaternion ort = CameraRig.centerEyeAnchor.rotation;
Vector3 ortEuler = ort.eulerAngles;
ortEuler.z = ortEuler.x = 0f;
ort = Quaternion.Euler(ortEuler);
Vector3 moveDir = Vector3.zero;
Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
moveDir += ort * (primaryAxis.x * Vector3.right);
moveDir += ort * (primaryAxis.y * Vector3.forward);
//_rigidbody.MovePosition(_rigidbody.transform.position + moveDir * Speed * Time.fixedDeltaTime);
_rigidbody.MovePosition(_rigidbody.position + moveDir * Speed * Time.fixedDeltaTime);
}
void SnapTurn()
{
if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickLeft) ||
(RotationEitherThumbstick && OVRInput.Get(OVRInput.Button.PrimaryThumbstickLeft)))
{
if (ReadyToSnapTurn)
{
ReadyToSnapTurn = false;
transform.RotateAround(CameraRig.centerEyeAnchor.position, Vector3.up, -RotationAngle);
}
}
else if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickRight) ||
(RotationEitherThumbstick && OVRInput.Get(OVRInput.Button.PrimaryThumbstickRight)))
{
if (ReadyToSnapTurn)
{
ReadyToSnapTurn = false;
transform.RotateAround(CameraRig.centerEyeAnchor.position, Vector3.up, RotationAngle);
}
}
else
{
ReadyToSnapTurn = true;
}
}
}
collider가 있어서 이 안으로 텔레포트 할 수 없다.
어싸인 확인
이건 엄지와 검지를 닿게 할 것인지를 결정
이제 핸드트래킹(손가락)으로도 턴을 적용 시킬 수 있다.
영상과 같이 길로만 이동할수 있따.
'산대특 > VRAR' 카테고리의 다른 글
[VR] Transformer Interaction (0) | 2024.04.23 |
---|---|
[VR]반대손 복사와 회전 및 던지기 (0) | 2024.04.19 |
[VR]총 잡기 - HandGun Grab (1) | 2024.04.18 |
Create Ghost Reticles (0) | 2024.04.18 |
Oculus Settings and Grab (0) | 2024.04.17 |