총 포탑에서 일하고 있습니다. 포탑을 포탑에서 꺼내는 것 외에는 모든 것이 작동합니다. 현재 사용되는 배럴은Unity3d C# 포탑 포탄이 움직이지 않을 것입니다.
입니다. void Start() { firingPointRight = GameObject.FindGameObjectWithTag ("FiringPointRight"). 변형; firingPointLeft = GameObject.FindGameObjectWithTag ("FiringPointLeft"). 변형; }
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