void Shoot() { currentBullets--; hudController.SetCurrentAmmo(currentBullets); EffectManager.Instance.SyncGunshotEffect(pointOfGunLocation.position, pointOfGunLocation.rotation, Vector3.zero, "foo");; gunAnimator.SetTrigger("ShotFired"); lastShotTime = Time.time; RaycastHit _hit; if ( Physics.Raycast( fpsCam.transform.position, fpsCam.transform.forward, out _hit, Mathf.Infinity, shootableMask ) ) { Shootable.ShootableType shootableType = _hit.transform.gameObject.GetComponent <Shootable>().shootableType; EffectManager.Instance.SyncGunHitEffect(_hit.point, shootableType); string hitTag = _hit.collider.tag; bool hitPlayer = hitTag == "PlayerHead" || hitTag == "PlayerBody" || hitTag == "PlayerLegs"; if (hitPlayer) { PhotonView photonView = PhotonView.Get(_hit.transform.parent.parent.gameObject); Debug.Log("DEBUG :: Hit player with viewID " + photonView.ViewID); photonView.RPC("RpcGetHit", RpcTarget.All, equippedWeapon.name, hitTag); } } }
void DoGunHitEffect(Vector3 position, Shootable.ShootableType shootableType) { AudioClip hitClip = null; switch (shootableType) { case Shootable.ShootableType.Terrain: AudioClip ricochetClip = ricochetClips[Random.Range(0, ricochetClips.Length)]; hitClip = ricochetClip; break; case Shootable.ShootableType.Player: hitClip = playerHitClip; VisualEffect tmpBloodspray = Instantiate(bloodSprayEffect, position, Quaternion.identity); Destroy(tmpBloodspray.gameObject, 4.0f); break; } PlaySoundFromLocation(position, hitClip); }
public void SyncGunHitEffect(Vector3 position, Shootable.ShootableType shootableType) { DoGunHitEffect(position, shootableType); photonView.RPC("RpcDoGunHitEffect", RpcTarget.Others, position, shootableType); }
void RpcDoGunHitEffect(Vector3 position, Shootable.ShootableType shootableType) { DoGunHitEffect(position, shootableType); }