using UnityEngine;
using System.Collections;
public class GetCurrentKey : MonoBehaviour {
KeyCode currentKey;
void Start ()
{
currentKey = KeyCode.Space;
}
void OnGUI()
{
if (Input.anyKeyDown)
{
Event e = Event.current;
if (e.isKey)
{
currentKey = e.keyCode;
Debug.Log("Current Key is : " + currentKey.ToString());
}
}
}
}
using UnityEngine;
using System.Collections;
public class Cube : MonoBehaviour { // Use this for initialization
void Start () { } // Update is called once per frame void Update () {
if(Input.GetKey(KeyCode.W)){//当鼠标按下W键时,小球向前移动
transform.Translate(Vector3.forward);
}
if(Input.GetKey(KeyCode.S)){当鼠标按下S键时,小球向后移动
transform.Translate(Vector3.back);
天猫双十一活动
} if(Input.GetKey(KeyCode.A)){当鼠标按下A键时,小球向左移动
transform.Translate(Vector3.left);
}
if(Input.GetKey(KeyCode.D)){当鼠标按下D键时,小球向右移动
transform.Translate(Vector3.right);
} if(Input.GetButton("Fire1")){//当点击鼠标左键时,小球撞塌墙
transform.rigidbody.AddForce(0,0,200);//物体向前移动的力为200
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有