Tag: unity2d

在继续使用C#Unityfunction之前,请等待协程完成

我正在努力让一个单位在Unity2d中通过网格移动。 我让运动没有问题。 我希望函数MovePlayer等到协程完成后再继续,所以程序将等到玩家完成移动后再发出更多订单。 这是我的代码:public class Player:MonoBehaviour { public Vector3 position; private Vector3 targetPosition; private float speed; void Awake () { speed = 2.0f; position = gameObject.transform.position; targetPosition = position; GameManager.instance.AddPlayerToList(this); //Register this player with our instance of GameManager by adding it to a list of Player objects. } //Function that moves the player, takes a […]