0
이 발췌 문장에서 발사체를 파괴하려는 시도가 작동하지 않습니다. 모든 제안을 부탁드립니다.Unity3D가 인스턴스화 된 발사체를 파괴하려고 시도합니다
Rigidbody InstantiateedProjectileLeft = Instantiate(cannonAmmo, firingPointLeft.transform.position, firingPointLeft.transform.rotation) as Rigidbody;
if (InstantiateedProjectileLeft != null)
{
//print ("Firing projectile");
InstantiateedProjectileLeft.transform.Translate(Vector3.forward);
InstantiateedProjectileLeft.rigidbody.AddForce(transform.forward * cannonAmmoSpeed);
//print (InstantiateedProjectileLeft.transform.position.y);
print ("Destroying left projectile");
//InstantiateedProjectileLeft.renderer.material.color = Color.clear;
Destroy(InstantiateedProjectileLeft, 1.0f); // Doesn't work
}
Rigidbody InstantiateedProjectileRight = Instantiate(cannonAmmo, firingPointRight.transform.position, firingPointRight.transform.rotation) as Rigidbody;
if (InstantiateedProjectileRight != null)
{
//print ("Firing projectile");
InstantiateedProjectileRight.transform.Translate(Vector3.forward);
InstantiateedProjectileRight.rigidbody.AddForce(transform.forward * cannonAmmoSpeed);
Destroy(InstantiateedProjectileRight, 1.0f); // Doesn't work
}
이 파괴 '시도 (InstantiatedProjectileLeft.gameObject, ...)' – luqui
감사합니다. gameObject가 작동합니다. – jadkins4