public override void useAsItem(Tile tileUsingUs) { if (_cooldownTimer > 0) { return; } // First, make sure we're aimed properly (to avoid shooting ourselves by accident) aim(); // Check to see if the muzzle is overlapping anything. int numBlockers = Physics2D.OverlapPointNonAlloc(muzzleFlashObj.transform.position, _maybeColliderResults); for (int i = 0; i < numBlockers && i < _maybeColliderResults.Length; i++) { if (!_maybeColliderResults[i].isTrigger && _maybeColliderResults[i] != mainCollider) { ObjShake maybeSpriteShake = _sprite.GetComponent <ObjShake>(); if (maybeSpriteShake != null) { maybeSpriteShake.shake(); } return; } } muzzleFlashObj.SetActive(true); Invoke("deactivateFlash", 0.1f); tileUsingUs.addForce(-recoilForce * tileUsingUs.aimDirection.normalized); // Let's spawn the bullet. The bullet will probably need to be a child of the room. GameObject newBullet = Instantiate(bulletPrefab); newBullet.transform.parent = tileUsingUs.transform.parent; newBullet.transform.position = muzzleFlashObj.transform.position; newBullet.transform.rotation = transform.rotation; newBullet.GetComponent <Tile>().init(); newBullet.GetComponent <Tile>().addForce(tileUsingUs.aimDirection.normalized * shootForce); _cooldownTimer = cooldownTime; }