Controller Colliders wont respond from one side only

So, it appears that there have been tons of questions relating to the CC collider not responding…

My situation works fine, except… a particular object will not call the method necessary when making collision with the PC if I walk up behind it as its moving away from my PC.

To understand more, this is a side scroller. You get power ups and jump on enemies, just like Mario. If I run up and collide with an enemy walking in the same direction, it will make contact (I die). If I do the same to the power up, which granted is going a little faster than the enemy, it will not respond. My PC just pushes the object and wont call the method.

Im using the exact same code to check for collision for both the enemy and powerup objects. I make this point because if I get in front of the powerup objects path, it does what its suppose to do upon collision. Why not from the other side? Any ideas what I could be missing here?

If you’re using the same code, this means that the problem is related to how you have the collider component set up or the actual position of the collider in the game. If it works from one side and not the other, I would assume that the collider needs to be scaled up a little bit. I’d also make sure that the powerup collider you are using has the “Is Trigger” boolean checked.

Did you checked if the power up collider is a trigger (Or not, depending on whether you use OnCollisionEnter or OnTriggerEnter) ?

Did you also checked if you have a kinematic Rigidbody attached to at least the powerup or the PlayerController ?

Otherwise, can you post your collision checking code ? But personally I think it’s mode due to a bad configuration with Colliders/Rigidbodies .

It’s possibly to do with the script you use. The way unity does checks for collisions is in sequence (seemingly random) which means that you can destroy/teleport/remove from contact one object in the collision then Unity checks for collision on the other side but the object it was colliding with is gone so nothing happens.

To fix this you should check for collisions in you OnTriggerEnter function then inside of Update or FixedUpdate have THAT call the function to do whatever operation you want if it meets whatever conditions you set it and then update the state of those objects all at once in update. That way you check all the conditions and then update all of For example.

This works:

    void OnTriggerEnter2D()
    {
        Debug.Log(gameObject.name + " Collision");
        
        health--;
        invulnTimer = invulnPeriod;
        gameObject.layer = 10;
    }

    void Update()
    {

        invulnTimer -= Time.deltaTime;
        if(invulnTimer <= 0)
        {
            gameObject.layer = correctLayer;
        }

        if (health <= 0)
        {
            Die();
        }
    }

    void Die()
    {
        Destroy(gameObject);
        
        Debug.Log(gameObject.name + " Object Removed - COMBAT DESTROYED");
    }

But this script below only works for the first object arbitrarily chosen by Unity:

    void OnTriggerEnter2D()
    {
        Debug.Log(gameObject.name + " Collision");
        
        health--;
        invulnTimer = invulnPeriod;
        gameObject.layer = 10;
    
        invulnTimer -= Time.deltaTime;
        if(invulnTimer <= 0)
        {
            gameObject.layer = correctLayer;
        }

        if (health <= 0)
        {
            Die();
        }
    }

    void Die()
    {
        Destroy(gameObject);
        
        Debug.Log(gameObject.name + " Object Removed - COMBAT DESTROYED");
    }