国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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ó)家法律
阿克陶县| 句容市| 邛崃市| 万全县| 乌拉特中旗| 宁波市| 乃东县| 全椒县| 得荣县| 瓮安县| 姚安县| 东源县| 上蔡县| 崇文区| 双江| 明水县| 城口县| 开江县| 镇安县| 罗定市| 乌兰察布市| 汾阳市| 静海县| 凉山| 湛江市| 弥勒县| 桂平市| 西林县| 克拉玛依市| 商河县| 民县| 玛多县| 曲松县| 志丹县| 庐江县| 祥云县| 广汉市| 高台县| 建水县| 龙井市| 山西省|