void Shoot() { playerAnim.SetTrigger("shoot"); shotgunModel.DOComplete(); shotgunModel.DOPunchPosition(new Vector3(0, 0, -punchStrenght), punchDuration, punchVibrato, punchElasticity); muzzleflash.Play(); RaycastHit hitInfo; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hitInfo, range, myLayerMask)) { Debug.Log(hitInfo.transform.name); Phish target = hitInfo.transform.GetComponent <Phish>(); if (target != null) { target.TakeDamage(damage); GameObject hitEnemy = Instantiate(enemyImpact, hitInfo.point, Quaternion.LookRotation(hitInfo.normal)); Destroy(hitEnemy, 0.5f); } else { GameObject impact = Instantiate(enviornmentImpact, hitInfo.point, Quaternion.LookRotation(hitInfo.normal)); Destroy(impact, 0.5f); } } FindObjectOfType <AudioManager>().Play("shootShotgun"); }
void Shoot() { playerAnim.SetTrigger("shoot"); gunModel.DOComplete(); gunModel.DOPunchPosition(new Vector3(0, 0, -punchStrenght), punchDuration, punchVibrato, punchElasticity); muzzleflash.Play(); ejectShell.Play(); RaycastHit hitInfo; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hitInfo, range, myLayerMask)) { Debug.Log(hitInfo.transform.name); Phish target = hitInfo.transform.GetComponent <Phish>(); if (target != null) { target.TakeDamage(damage); GameObject hitEnemy = Instantiate(enemyImpact, hitInfo.point, Quaternion.LookRotation(hitInfo.normal)); Destroy(hitEnemy, 0.5f); } else { GameObject impact = Instantiate(enviornmentImpact, hitInfo.point, Quaternion.LookRotation(hitInfo.normal)); Destroy(impact, 0.5f); } } if (currentShotFrame == 0) { GameObject gunShot = Instantiate(Gunshot, this.transform.position, this.transform.rotation); gunShot.transform.parent = this.transform; currentShotFrame = framesBeforeNextShot; } else { currentShotFrame--; } }
void Slash() { playerAnim.SetTrigger("Attack"); RaycastHit hitInfo; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hitInfo, distance, myLayerMask)) { Debug.Log(hitInfo.transform.name); Phish target = hitInfo.transform.GetComponent <Phish>(); if (target != null) { target.TakeDamage(damage); GameObject hitEnemy = Instantiate(enemyImpact, hitInfo.point, Quaternion.LookRotation(hitInfo.normal)); Destroy(hitEnemy, 2f); } else { GameObject impact = Instantiate(enviornmentImpact, hitInfo.point, Quaternion.LookRotation(hitInfo.normal)); Destroy(impact, 2f); } } }