Created
November 21, 2017 21:55
-
-
Save kazukitanaka0611/901832de8587acc3fcdc13874aac35d1 to your computer and use it in GitHub Desktop.
Fove Player Move
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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