using System.Collections; using System.Collections.Generic; using UnityEngine; public class Shoot : MonoBehaviour { public GameObject bullet; public Transform bullpos; public float speed = 1000f; public float bulletTime = 10f; void Update() { if (Input.GetButtonDown("Fire1")) { GameObject go = Instantiate(bullet, bullpos.position, Quaternion.Euler(0, 0, 0)); go.GetComponent().AddForce(-transform.forward * speed); Destroy(go, bulletTime); } } }