using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RocketLauncher : MonoBehaviour
{
public Rigidbody rocketPrefab;
public Transform barrelEnd;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1")) {
Shoot();
}
}
void Shoot() {
Rigidbody rocketInstance;
rocketInstance = Instantiate(rocketPrefab, barrelEnd.position, barrelEnd.rotation) as Rigidbody;
rocketInstance.AddForce(barrelEnd.forward * 1000);
}
}