|
|
|
|
|
|
public class GunController : MonoBehaviour |
|
|
|
{ |
|
|
|
public bool AllowKeyboardInput = true; //this mode ignores player input
|
|
|
|
private bool initialized; //has this robot been initialized
|
|
|
|
public bool initialized; //has this robot been initialized
|
|
|
|
public KeyCode shootKey = KeyCode.J; |
|
|
|
[Header("AUTOSHOOT")] public bool autoShootEnabled; |
|
|
|
|
|
|
|
|
|
|
public GameObject projectilePrefab; |
|
|
|
public int numberOfProjectilesToPool = 25; |
|
|
|
public Transform projectileOrigin; //the transform the projectile will originate from
|
|
|
|
private List<Projectile> projectilePoolList = new List<Projectile>(); //projectiles to shoot
|
|
|
|
// public List<Projectile> projectilePoolList = new List<Projectile>(); //projectiles to shoot
|
|
|
|
public List<Rigidbody> projectilePoolList = new List<Rigidbody>(); //projectiles to shoot
|
|
|
|
|
|
|
|
//FORCES
|
|
|
|
[Header("FORCES")] |
|
|
|
|
|
|
{ |
|
|
|
impulseSource = GetComponent<CinemachineImpulseSource>(); |
|
|
|
GameObject obj = Instantiate(projectilePrefab, transform.position, Quaternion.identity); |
|
|
|
Projectile p = obj.GetComponent<Projectile>(); |
|
|
|
Rigidbody p = obj.GetComponent<Rigidbody>(); |
|
|
|
projectilePoolList.Add(p); |
|
|
|
p.transform.position = projectileOrigin.position; |
|
|
|
// p.projectileController = this;
|
|
|
|
|
|
|
{ |
|
|
|
if (!item.gameObject.activeInHierarchy) |
|
|
|
{ |
|
|
|
FireProjectile(item.rb); |
|
|
|
FireProjectile(item); |
|
|
|
// FireProjectile(item.rb);
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|