我想让我的射弹移动到特定的点(0,0,10)
我试过下面的代码,但它不能工作
if (Input.GetKey("right shift")||Input.GetKey("left shift")) {
Rigidbody clone;
clone = Instantiate(projectile1, transform.position, transform.rotation) as Rigidbody;
clone.velocity=new Vector3(0,0,10);有人能帮上忙吗?
发布于 2013-01-14 08:03:52
如果你想要一个恒定的速度,改用MoveTowards : MoveTowards( pointA,pointB,Delta值)返回线上的一个点a点-点B距离pointA的增量单位-并被钳制到pointB,因此它永远不会超出目标点。
if (Input.GetKey("right shift")||Input.GetKey("left shift")) {
Rigidbody clone;
clone = Instantiate(projectile1, transform.position, transform.rotation) as Rigidbody;
clone.position = Vector3.MoveTowards(transform.position, new Vector3(0,0,10), Time.deltaTime * speed); }其中速度以米(或单位)每秒为单位。
https://stackoverflow.com/questions/14309669
复制相似问题