transform.Translate(new Vector3(x, y, 0) * Time.deltaTime * speed )
控制物体移动
Material
Albedo 选择颜色
Metallic 金属质感程度
Smoothness 光滑度
前面的小圆圈点击可以选择贴图
脚本
控制相机移动
publicclassMovement:MonoBehaviour{publicfloat speed =3;// Use this for initializationvoid Start (){}// Update is called once per framevoid Update (){float x = Input.GetAxis("Horizontal");float y = Input.GetAxis("Vertical");// Translate()控制方向移动// Vector(),如果你一直按着右键,每一帧移动1米,1s有几十帧// Time.deltaTime时间间隔,每秒
transform.Translate(newVector3(x, y,0)* Time.deltaTime * speed );}}
控制射击
publicclassShoot:MonoBehaviour{publicGameObject bullet;publicfloat speed =5f;// Use this for initializationvoid Start (){}// Update is called once per framevoid Update (){if( Input.GetMouseButtonDown(0))// 检测是否鼠标按下,0代表带是鼠标左键{//instantiate a GameObject bullet,transform代表的是当前对象的transform组件//这里获得了cinema的position和rotationGameObject b = GameObject.Instantiate(bullet, transform.position, transform.rotation);Rigidbody rgb = b.GetComponent<Rigidbody>();//获得刚体组件Rigidbody
rgb.velocity = transform.forward * speed;//forward意味着z轴为1,xy为0}}}