// public void OnProjectileHit(Projectile projectile) { if (!Owner && GameObj.transform.parent) { Owner = GameObj.transform.parent.gameObject.GetFirstComponentUpward <AgentHuman>(); } if ((Owner != null) && (Owner.IsFriend(projectile.Agent) == true)) { projectile.ignoreThisHit = true; return; } Vector3 impulse = (projectile.Transform.forward * (projectile.Impulse * 0.005f)) + (Vector3.up * (projectile.Impulse * 0.002f)); // Debug.Log ("HatObject, impulse=" + impulse.ToString("F5") + ", projectile.Impulse=" + projectile.Impulse.ToString("F5") + ", impulse.magnitude=" + impulse.magnitude); // Debug.DrawLine(GameObj.transform.position, GameObj.transform.position + impulse, Color.red, 5.0f); if (uLink.Network.isServer) { if (Owner) { //send impulse to clients Owner.NetworkView.RPC("ShotOffHat", uLink.RPCMode.Others, impulse, false); //shot off the hat on server Owner.ShotOffHat(impulse, true); } } else { //apply impulse to a hat which is already shot off if (null == GameObj.transform.parent) { GameObj.GetComponent <Rigidbody>().isKinematic = false; GameObj.GetComponent <Rigidbody>().useGravity = true; GameObj.GetComponent <Rigidbody>().AddForce(impulse, ForceMode.Impulse); } else { return; // on client and still on head --> do nothing } } DestroyTime = Time.timeSinceLevelLoad + 20; //destroy hat after 20 seconds }