void OnControllerColliderHit(ControllerColliderHit hit) { pushPower = Random.Range(controller.competence.pushPower - controller.competence.pushPowerDelta, controller.competence.pushPower + controller.competence.pushPowerDelta); Rigidbody body = hit.collider.attachedRigidbody; // no rigidbody if (body == null || body.isKinematic) { return; } // Only push rigidbodies in the right layers LayerMask bodyLayerMask = 1 << body.gameObject.layer; if ((bodyLayerMask & pushLayers.value) == 0) { return; } // Calculate push direction from move direction, we only push objects to the sides // never up and down Vector3 pushDir = new Vector3(hit.moveDirection.x, 0.1f, hit.moveDirection.z); // We push objects below us to take objects to ground if (hit.moveDirection.y < -0.3) { pushDir = hit.transform.position - transform.position; pushDir.y -= 0.5f; body.velocity += pushDir * pushPower; return; } // push with move speed but never more than walkspeed body.velocity += pushDir * pushPower * Mathf.Min(controller.GetSpeed(), controller.movement.walkSpeed); //controller.SendMessage("DidAttack02", SendMessageOptions.DontRequireReceiver); //controller.SendMessage("DidAttack", SendMessageOptions.DontRequireReceiver); }