无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

unity3d VR游戲控制基本腳本。

2021-05-30 10:38 作者:擁抱大自然  | 我要投稿

手機(jī)連接藍(lán)牙手柄或者鍵盤。

上下左右鍵控制前后左右移動(dòng)。

雙擊左或者右,視角轉(zhuǎn)動(dòng)45°。

(即便你沒有陀螺儀的手機(jī)一樣可以用。)

手機(jī)左右傾斜30度,視角左右移動(dòng)。

手機(jī)向前傾45度,人物向前走。

(你手機(jī)有陀螺儀,但沒有連接控制手柄或者鍵盤,一樣可以用)


=======


using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class playerControl : MonoBehaviour

{

? ? public int playerSpeed = 1;

? ? public int rSpeed = 50;

? ? public int headLeanAngle=45;

? ? public int headTilt=30;? ??


? ? public float DOUBLE_CLICK_TIME = 0.2f;

? ? private float lastClickTime;??

? ?

? ? void Update()

? ? {? ? ? ?

? ? ? ? //KeyBoard Input:=============================

? ? ? ? if (Input.GetKey("up"))

? ? ? ? {

? ? ? ? ? ? ?transform.position = transform.position + Camera.main.transform.forward * playerSpeed * Time.deltaTime;

? ? ? ? }


? ? ? ? if (Input.GetKey("down"))

? ? ? ? {

? ? ? ? ? ? ?transform.position = transform.position - Camera.main.transform.forward * playerSpeed * Time.deltaTime;

? ? ? ? }


? ? ? ? if (Input.GetKey("left"))

? ? ? ? {

? ? ? ? ? ? //transform.Rotate(new Vector3(0, -1, 0) * Time.deltaTime * playerSpeed*rSpeed, Space.World);

? ? ? ? ? ? ?transform.position = transform.position - Camera.main.transform.right * playerSpeed * Time.deltaTime;

? ? ? ? }


? ? ? ? if (Input.GetKey("right"))

? ? ? ? {

? ? ? ? ? ? //transform.Rotate(new Vector3(0, 1, 0) * Time.deltaTime * playerSpeed*rSpeed, Space.World);

? ? ? ? ? ? ?transform.position = transform.position + Camera.main.transform.right * playerSpeed * Time.deltaTime;

? ? ? ? }


? ? ? ? //keyboard double click:

? ? ? ? if (Input.GetKeyUp("right"))

? ? ? ? {

? ? ? ? ? ? float timeSinceLastClick = Time.time - lastClickTime;

? ? ? ? ? ? Debug.Log(lastClickTime +"? ?"+ Time.time +"? ?"+ timeSinceLastClick );

? ? ? ? ? ? if(timeSinceLastClick<=DOUBLE_CLICK_TIME)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? transform.Rotate(new Vector3(0, 1, 0) * 30, Space.World);

? ? ? ? ? ? }

? ? ? ? ? ? lastClickTime = Time.time;

? ? ? ? }


? ? ? ? if (Input.GetKeyUp("left"))

? ? ? ? {

? ? ? ? ? ? float timeSinceLastClick = Time.time - lastClickTime;

? ? ? ? ? ? Debug.Log(lastClickTime +"? ?"+ Time.time +"? ?"+ timeSinceLastClick );

? ? ? ? ? ? if(timeSinceLastClick<=DOUBLE_CLICK_TIME)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? transform.Rotate(new Vector3(0, -1, 0) * 30, Space.World);

? ? ? ? ? ? }

? ? ? ? ? ? lastClickTime = Time.time;

? ? ? ? }


? ? ? ? //Head Gesture input:================================


? ? ? ? Debug.Log(Camera.main.transform.eulerAngles);



? ? ? ? if (Camera.main.transform.eulerAngles.z>headTilt && Camera.main.transform.eulerAngles.z<90)

? ? ? ? {

? ? ? ? ? ? ? transform.Rotate(new Vector3(0, -1, 0) * Time.deltaTime * playerSpeed*rSpeed, Space.World);

? ? ? ? }


? ? ? ? if (Camera.main.transform.eulerAngles.z>270 && Camera.main.transform.eulerAngles.z<360-headTilt)

? ? ? ? {

? ? ? ? ? ? ? transform.Rotate(new Vector3(0, 1, 0) * Time.deltaTime * playerSpeed*rSpeed, Space.World);

? ? ? ? }


? ? ? ? if (Camera.main.transform.eulerAngles.x>headLeanAngle && Camera.main.transform.eulerAngles.x<90)

? ? ? ? {

? ? ? ? ? ? ?transform.position = transform.position + Camera.main.transform.forward * playerSpeed * Time.deltaTime;

? ? ? ? }

? ? }

}


unity3d VR游戲控制基本腳本。的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
汝城县| 翁牛特旗| 永和县| 九台市| 西华县| 耒阳市| 阿拉尔市| 绩溪县| 宝坻区| 咸宁市| 荆州市| 灌阳县| 武汉市| 雅江县| 海城市| 龙江县| 棋牌| 科技| 甘泉县| 会同县| 玉屏| 万源市| 嘉善县| 顺义区| 锦屏县| 庆安县| 和田县| 日照市| 璧山县| 安阳县| 新巴尔虎右旗| 台南市| 芒康县| 桐柏县| 重庆市| 紫云| 静宁县| 开封县| 宜阳县| 七台河市| 城步|