五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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ó)家法律
遂昌县| 柳江县| 德惠市| 济阳县| 上蔡县| 武安市| 会昌县| 临沧市| 同仁县| 汾阳市| 禹城市| 木兰县| 涟源市| 贺州市| 靖江市| 湖南省| 鲁山县| 通榆县| 眉山市| 新安县| 磐安县| 宜宾县| 中宁县| 望奎县| 若尔盖县| 丽水市| 崇左市| 廊坊市| 尉犁县| 长寿区| 中阳县| 怀集县| 陈巴尔虎旗| 五指山市| 正阳县| 专栏| 沂南县| 桃源县| 葵青区| 昌乐县| 大同县|