void Start() { animator = this.GetComponent<Animator>(); ragdollController = this.transform.root.gameObject.GetComponent<BodyPhysicsController>(); PhotonView view = this.GetComponent<PhotonView>(); isControlledLocally = view.isMine; }
void OnCollisionEnter (Collision coll) { Rigidbody hitRigidbody; GameObject hitGameObject; GameObject hitParent; hitParent = coll.gameObject.transform.root.gameObject; // get the parent object's tag bpController = hitParent.GetComponent<BodyPhysicsController>(); // get the parent's BodyPhysicsController so we can set the currOffBalance value hitGameObject = coll.gameObject; // reference the actual spawned player object so we can add force if (hitParent.tag == "Player" && (bpController.m_currOffBalance <= bpController.m_balance)) // add force if we hit a player character that's not already off balance { hitRigidbody = hitGameObject.GetComponent<Rigidbody>(); bpController.m_currOffBalance = bpController.m_balance * 1.2f; hitRigidbody.AddForce(hitGameObject.transform.forward * -1 * applyForce); RandomJiggleTarget(100, 75, 35, 0); } }