五月天青色头像情侣网名,国产亚洲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ó)家法律
房山区| 昔阳县| 图木舒克市| 保靖县| 砚山县| 沭阳县| 台南县| 苏尼特右旗| 海伦市| 金门县| 凭祥市| 阳春市| 大足县| 斗六市| 吉安县| 巧家县| 方正县| 恩施市| 苍梧县| 大余县| 武乡县| 厦门市| 南丰县| 盐山县| 桦南县| 金塔县| 阿坝| 建昌县| 长葛市| 青海省| 开阳县| 西盟| 桑植县| 阿拉善右旗| 边坝县| 德阳市| 河西区| 大竹县| 巴东县| 库尔勒市| 安化县|