获取鼠标和键盘的输入

usingUnityEngine;

usingSystem.Collections;

publicclassCarMove:MonoBehaviour{

//publicfloatspeed;

//Usethisforinitialization

voidStart(){

}

//Updateiscalledonceperframe

voidUpdate(){

//键盘

//floathor=Input.GetAxis("Horizontal");

//floatver=Input.GetAxis("Vertical");

//前后左右移动

//transform.position+=Vector3.forward*speed*ver*Time.deltaTime;

//transform.position+=Vector3.forward*speed*hor*Time.deltaTime;

//transform.position+=newVector3(1*hor,0,1*ver)*speed*Time.deltaTime;

//竖直轴控制前后移动

//transform.position+=transform.forward*speed*ver*Time.deltaTime;

////水平轴控制左右旋转

//transform.Rotate(transform.up,20*hor*Time.deltaTime);

//

//

////        print (hor);

//

//print(Input.GetAxis("Fire1"));

//鼠标

//0代表鼠标左键,1代表鼠标右键,2代表滚轮键

//if(Input.GetMouseButton(0)){

//

//print("MouseButton");

//}

//if(Input.GetMouseButtonDown(0)){

//

//print("lao");

//}

//移动一次的距离

//floatdistence=Input.GetAxis("MouseX");

//print(distence);

//

//floatdistence1=Input.GetAxis("MouseY");

//print(distence1);

floatdistence2=Input.GetAxis("MouseScrollWheel");

print(distence2);

}

}

你可能感兴趣的:(获取鼠标和键盘的输入)