// Start is called before the first frame update void Start() { parentController = character.GetComponentInChildren <GunContoroller>(); speed = parentController.bulletSpeed; rb = GetComponent <Rigidbody>(); rb.velocity = transform.forward * speed; timeInAir = parentController.timeInAir; rb.velocity = transform.up * parentController.bulletSpeed; transform.rotation = rotation; damage = parentController.damagePerShot; StartCoroutine(Time()); }
public void PickupGun(GameObject gun, GameObject gunpPickup, GunContoroller controller) { if (gun == null) { Debug.Log("Gun Null"); } if (gunpPickup == null) { Debug.Log("gunpickup null"); } if (controller) { if (currentGun != null) { lastPickup = Instantiate(gunPickupItem, transform.position + transform.forward * dropDistance + dropOffset, dropRotation); lastPickupController = lastPickup.GetComponent <PickupController>(); Destroy(currentGun); lastPickupController.loadedAmmo = gunController.loadedAmmo; controller.crossHair.SetActive(false); } } currentGun = Instantiate(gun, controller.holdPosition, controller.holdRotation, character); gunController = currentGun.GetComponent <GunContoroller>(); gameController.gunController = gunController; gunController.SetPosition(); Debug.Log("Close"); gunPickupItem = gunpPickup.gameObject; currentGun.SendMessage("SetFireable"); UpdateUI(); if (lastPickupController != null) { gunController.loadedAmmo = lastPickupController.loadedAmmo; } gunImage.color = new Color(0, 0, 0, 255); UpdateUI(); }
private void Start() { Pickupable = false; pickup = GameObject.Find(Gun.name + "_Pickup_Main"); controller = Gun.GetComponent <GunContoroller>(); }