unity 控制一个盒子移动代码

//个人原创转载请声明转载自http://www.cnblogs.com/suxsho

var
target : Transform; var smoothTime : float; private var velocity = Vector3.zero; var x = 10; var fireRate : float = 0.0; private var nextFire : float = 0.0; var postrue : boolean = false; function Update () { target.position.y = x; //TIME if (Time.time > nextFire) { nextFire = Time.time + fireRate; postrue = true; } //MOVE if (postrue) { smoothTime = 0.05; //Random.value; fireRate = 0.15; //Random.Range(0.1,0.5); x *= -1; postrue = false; } transform.position = Vector3.SmoothDamp(transform.position, target.position, velocity, smoothTime); print (smoothTime); }
原文地址:https://www.cnblogs.com/suxsho/p/3008305.html