using UnityEngine;public class SimpleShoot : MonoBehaviour{ public GameObject bulletPrefab; // 子弹预制体 public Transform firePoint; // 发射点 public float bulletSpeed = 20.0f; // 子弹速度 void Update() { if (Input.GetButtonDown("Fire1")) // 按下射击键 { Shoot(); } } void Shoot() { GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation) as GameObject; bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward * bulletSpeed; }}