Can anyone tell me why I can't get "ControllerColliderHit" to trigger?

I'm hoping that I'm just overlooking something silly, but i just cant seem to figure out where I'm going wrong here. Basically I am trying to push a Rigidbody cube with a CharacterController. I have a player object with a character controller, all of the movement is done using the Move action through script, and i have a seperate script attached to the same object that simply handles pushing objects :

public class PushRigidbodies : MonoBehaviour
    public LayerMask pushLayers = new LayerMask();
    [Range(0.5f, 5f)] public float strength = 1.1f;

    public void Reset()
        pushLayers = LayerMask.GetMask("Default");

    public void PushRigidBodies(ControllerColliderHit hit)
        Debug.Log("Collision Detected!");
        var body = hit.collider.attachedRigidbody;
        if (body == null || body.isKinematic) return;

        var bodyLayerMask = 1 << body.gameObject.layer;
        if ((bodyLayerMask & pushLayers.value) == 0) return;

        if (hit.moveDirection.y < -0.3f) return;

        Vector3 pushDir = new Vector3(hit.moveDirection.x, 0.0f, hit.moveDirection.z);

        body.AddForce(pushDir * strength, ForceMode.Impulse);

However, the debug log is never called when running into objects on the specified layer and they behave as impassable walls.. The cubes I am trying to push have both a box collider (not set to trigger) & a Rigidbody component (Using gravity, not kenematic), and they can be pushed and moved by other Rigidbodies just fine. I hope all of that makes sense and if I left out any important details please let me know, thanks!!

Well what's calling this method? It's not a Unity message. It should be called OnControllerColliderHit if you want Unity to call it.

1 Like

..oh my gosh I knew it was something silly like that!! I totally forgot to call the script from my main object >_< its working as expected now.. Thank you!!

1 Like