Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kazukitanaka0611/901832de8587acc3fcdc13874aac35d1 to your computer and use it in GitHub Desktop.
Save kazukitanaka0611/901832de8587acc3fcdc13874aac35d1 to your computer and use it in GitHub Desktop.
Fove Player Move
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
[SerializeField] private float moveSpeed = 2.0f;
[SerializeField] private float moveAngleX = 20.0f;
// Update is called once per frame
void Update ()
{
// 1.カメラの傾きを取得
float rotationX = FoveInterface.GetHMDRotation().eulerAngles.x;
Debug.Log(rotationX);
// 2.ある角度以内であれば前進させる
if (moveAngleX < rotationX && rotationX < 90.0f)
{
this.transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
}
this.transform.Rotate(new Vector3(0, -FoveInterface.GetHMDRotation().y, 0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment