如何使用GameObject
方法将GameObject
移至另一个Vector3.MoveTowards
?
继承我目前的代码:
void update()
{
TargetObject.transform.position = Vector3.MoveTowards (TargetObject.transform.position, Cube.transform.position , MaxDistanceDelta);
}
答案 0 :(得分:4)
void Update() {
myGameObject.transform.position = Vector3.MoveTowards(myGameObject.transform.position, targetObject.transform.position, Time.deltaTime * speed);
}