Стрельба патронами из пушки
// создать пульку перед пушкой
GameObject bullet = Instantiate(myBulletPrefab) as GameObject;
bullet.transform.position = transform.TransformPoint(Vector3.forward * 6.4f);// повернуть пульку
Vector3 pos = transform.position - bullet.transform.position;
Quaternion rotation = Quaternion.LookRotation(pos);
bullet.transform.rotation = rotation;
bullet.transform.Rotate(90, 0, 0);// добавить силу к пульке (мгновенно)
Rigidbody rrr = bullet.GetComponent<Rigidbody>();
Vector3 vvv = transform.forward * 5300;
vvv.y = 1115.5f;
rrr.AddForce(vvv);Last updated