【发布时间】:2020-08-19 11:37:31
【问题描述】:
我实例化了一个预制对象(子弹),如果它在 yield 返回秒数时被破坏,Unity 在我将刚体速度设置为零的行处抛出错误。无论我把它们放在哪里,它都不关心对象空检查。该脚本附加到实例化的游戏对象。
public IEnumerator GetOutState (GameObject target) {
state = State.GetOut;
if (state == State.GetOut && gameObject != null) {
rbMissile.velocity = -transform.up * speed;
yield return new WaitForSecondsRealtime(1);
rbMissile.velocity = Vector2.zero;
StartCoroutine(FlyState(target));
}
}
【问题讨论】:
标签: unity3d