//Range attack method public virtual void RangeAttack() { GameObject rangeWeaponGO = Instantiate(rangeWeaponPrefab, rangeWeaponStartPos.position, Quaternion.identity); //spawn weapon float rotAngle = Mathf.Acos(transform.localScale.x) * Mathf.Rad2Deg; //calculate rotate angle by rotate our gameobject rangeWeaponGO.transform.Rotate(new Vector3(0, rotAngle, 0)); //rotate RangeWeapon rangeWeapon = rangeWeaponGO.GetComponent <RangeWeapon>(); rangeWeapon.playerDamage = rangeWeaponDamage.Random(); //Get random damage rangeWeapon.fromPlayer = isPlayer; }
//Shoot method void Shoot() { if (shootRateTimer > 0) { shootRateTimer -= Time.deltaTime; } else { GameObject weapon = Instantiate(weaponPrefab, shootStartPos.position, shootStartPos.rotation); //Spawn weapon RangeWeapon rangeWeapon = weapon.GetComponent <RangeWeapon>(); //Get component rangeWeapon.fromPlayer = false; rangeWeapon.damage = damageRange.Random(); //Get damage value shootRateTimer = shootRate; //set timer } }