using UnityEngine; public class MonsterShoot2D : MonoBehaviour { public GameObject bullet; public GameObject bulletPos; public float horizontal = 500.0f; public float vertical = 0.0f; public float bulletTime = 5.0f; public float firePause = 3.0f; public float angle = 0f; void Start() { InvokeRepeating("F1", 1.0f, firePause); } void F1() { GameObject go = Instantiate(bullet, bulletPos.transform.position, Quaternion.Euler(0f, 0f, angle)); go.GetComponent().AddForce(new Vector2(horizontal, vertical)); Destroy(go, bulletTime); } }