学习笔记:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class TransformPointTest : MonoBehaviour { public Transform Cube; void FixedUpdate () { // vector3.clampMagnitude(vector,maxlength) //返回原向量vector的拷贝,并且它的模长最大不超过maxlength的长度 Cube.position = Vector3.ClampMagnitude(Cube.position, 5); float x= Input.GetAxis("Horizontal");//对应键盘上的A键和D键 或←键和→键 float z = Input.GetAxis("Vertical"); //对应键盘上的W键和S键 或↑键和↓键 float h = Input.GetAxis("Mouse X"); //对应X方向上鼠标的移动,在移动设备上也可以这样 float v = Input.GetAxis("Mouse Y"); //对应Y方向上鼠标的移动,在移动设备上也可以这样 float m = Input.GetAxis("Fire1"); //对应鼠标左键或left+Ctrl float n = Input.GetAxis("Fire2"); //对应鼠标右键或left+Alt float k = Input.GetAxis("Fire3"); //对应鼠标中键或left+shift float m1 = Input.GetAxisRaw("Fire1"); //input.getAxis()和input.getAxisRaw()的区别 //input.getAxis()的返回值m从0渐变为1或者-1 //input.getAxisRaw()的返回值从0变成1或者-1,没有渐变 // transform.Translate(x,0,z); // transform.Translate(h,0,v); transform.Translate(0,0,m1);
playerrb.AddForce(new Vector3(x,0,z));
} }
标签:鼠标,GetAxis,float,unity,input,Input,对应 From: https://www.cnblogs.com/misakayoucn/p/17629714.html