0
我正在炮塔上工作。除了將炮彈射出炮塔炮管外,我已經完成了所有工作。目前,唯一使用的桶是Unity3d C#炮塔炮彈不會移動
void Start(){ firingPointRight = GameObject.FindGameObjectWithTag(「FiringPointRight」)。transform; firingPointLeft = GameObject.FindGameObjectWithTag(「FiringPointLeft」)。transform; }
void Update() {
if(Input.GetMouseButton(0)){
count++;
if (count >= maxCount)
{
count = 0;
//Debug.Log ("FIRE");
firingPointRight = GameObject.FindGameObjectWithTag ("FiringPointRight").transform;
firingPointLeft = GameObject.FindGameObjectWithTag ("FiringPointLeft").transform;
// Create cannon muzzle fire effect.
GameObject e1 = Instantiate (cannonMuzzleFire) as GameObject;
e1.transform.position = firingPointRight.transform.position;
e1.transform.rotation = firingPointRight.transform.rotation;
Destroy (e1, 0.03f);
GameObject e2 = Instantiate (cannonMuzzleFire) as GameObject;
e2.transform.position = firingPointLeft.transform.position;
e2.transform.rotation = firingPointLeft.transform.rotation;
Destroy (e2, 0.03f);
//-------------------------------------------
//Left cannon. Fire projectile from cannon.
//Debug.Log ("Firing Left");
Rigidbody InstantiateedProjectile = Instantiate(cannonAmmo, firingPointLeft.transform.position, firingPointLeft.transform.rotation) as Rigidbody;
if (InstantiateedProjectile != null)
{
print ("Firing projectile");
InstantiateedProjectile.transform.Translate(Vector3.forward * cannonAmmoSpeed * Time.deltaTime);
}
}
}
感謝您的提示。通過在檢查器中取消選中剛體的Is Kinematic複選框來解決問題。我也使用了拋射速度。 – jadkins4 2014-11-07 00:08:11