public void RPC_Shoot() { viseff.Play(); /* * if(gameObject.CompareTag("Turret") != true) * { * hporsp.playerAM -= 1; * hporsp.am.AmmoV -= 1; * } */ RaycastHit hit; if (Physics.Raycast(player.transform.position, player.transform.forward, out hit, range)) { //Debug.Log(hit.transform.name); HPSPAM target = hit.transform.GetComponent <HPSPAM>(); HPSPAM enemy = hit.transform.gameObject.GetComponent <HPSPAM>(); if (hit.transform.tag == "Player") { DealDamage(enemy); } GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impactGO, 2); } }
void DealDamage(HPSPAM enemy) { if (enemy.playerSP > 0) { enemy.TakeDamageSP(hporsp.playerDamage); enemy.playerSP -= hporsp.playerDamage; } else if (enemy.playerSP <= 0) { enemy.TakeDamageHP(hporsp.playerDamage); enemy.playerHP -= enemy.playerDamage; } }