标签:
到目前为止已经完成大部分工作。
学到的新内容:
1、
if (transform.position.y < 4 && transform.position.y > -4) transform.Translate(0, moveSpeed * Time.deltaTime * Input.GetAxis("Vertical"), 0); if (transform.position.y >= 4) transform.position = new Vector3(transform.position.x, 3.9f, transform.position.z); if (transform.position.y <= -4) transform.position = new Vector3(transform.position.x, -3.9f, transform.position.z);
Vertical,比起用判断GetKeyDown,这个更有效,或者是说GetAxis更有效。
2、
Vector3 tarPos, objPos, direction; public GameObject bullet; GameObject createBallPosition; float bulletShotTime = 0;
//使gameobject朝向鼠标,利用向量 tarPos = Input.mousePosition; objPos = Camera.main.WorldToScreenPoint(transform.position); direction = tarPos - objPos; direction.z = 0f; //右面朝向鼠标 if (transform.rotation.z < 0.6 && transform.rotation.z > -0.6) transform.right = direction; if (transform.rotation.z >= 0.6) transform.rotation = new Quaternion(0, 0, 0.59f, 1); if (transform.rotation.z <= -0.6) transform.rotation = new Quaternion(0, 0, -0.59f, 1);
实现射击武器一直指向鼠标,并加限制界限
之后就是些碰撞检测等琐碎的已经熟练使用的知识点了。
标签:
原文地址:http://www.cnblogs.com/wayne-tao/p/5024012.html