我有这个代码:
void OnCollisionEnter (Collision collision)
{
if (canCollide == true) {
canCollide = false;
ContactPoint contactPoint = collision.contacts [0];
GameObject cube = GameObject.CreatePrimitive (PrimitiveType.Cube);
cube.transform.localScale = new Vector3 (5, 5, 5);
cube.transform.position = contactPoint.point;
iTween.MoveTo (cube, iTween.Hash (
"y", 40,
"time", 0.5));
iTween.MoveTo (cube, iTween.Hash (
"position", new Vector3 (55, 79, 10),
"time", 0.5f,
"delay", 0.5f,
"oncompletetarget", GameObject.Find ("PlayerCar"),
"oncomplete", "IncrementGauge"));
Destroy (cube, 1.1f);
}
}
这工作正常,两个动画都是按顺序排列的。但是时间的总和应该是1秒。但是 Destroy() 不能延迟 1 秒,它必须至少为 1.1 秒。为什么?我能否以某种方式更快地破坏立方体并且仍然触发 IncrementGauge()(Destroy 时 1 秒,防止触发 IncrementGauge())。
谢谢。