public override void ProjectileHit(Projectile projectile, RaycastHit hitInfo) { //only the master client can process the shot upon hit if (!photonView.IsMine) { return; } GameObject hitObject = hitInfo.collider.gameObject; string hitPoint = hitInfo.point.ToString(); PhotonView hitObjectView = hitInfo.collider.gameObject.GetComponent <PhotonView>(); IDamageable damageable = hitObject.gameObject.transform.root.GetComponent <IDamageable>(); if (damageable != null) { damageable.GetHit(hitInfo, projectile.Damage, projectile.Knockback); } IHittable hittable = hitObject.gameObject.GetComponent <IHittable>(); if (hittable != null) { hittable.GetHit(); } photonView.RPC("NetProjectileHit", RpcTarget.All, projectile.Index, hitPoint); }
public virtual void Damage(IHittable hittable, RaycastHit hit) { float distance = (hit.transform.position - shotOrigin.transform.position).magnitude; // The totalDamage is equal to the damage float totalDamage = damage - ((distance / shotRange) * damage * damageDropoffModifier); // Cause the hittable to get hit; hittable.GetHit(hit.point, shotOrigin.forward, totalDamage); }