Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Thin collider not detecting collision

Discussion in 'Physics' started by pixelf0x300, Nov 10, 2019.

  1. pixelf0x300

    pixelf0x300

    Joined:
    Nov 10, 2019
    Posts:
    1
    I'm trying to make a 2D plataformer with gravity mechanics where the gravity inverters are lines (like in vvvvvv), but I'm having problems with the colliders.
    I've reached to make them work "as intended": they revert the gravity and so. But if the coliders from both player and the inverter line are thick enough, the player can be in reversed gravity in areas i dont want to.

    Problem 1:
    Lets say there is area A (intended to be normal gravity) at left, and area B (reversed gravity) at right, and the gravity inverter between both. The player is a square and starts in the area A, then touches the inverter line, so its gravity is inverted, but before stopping touching the line, it returns to area A. Now the player has inverted gravity in the area i want normal gravity only.

    Problem 2:
    The character has a regular boxCollider2D, that collides with walls and floors, and then has a empty child with a 0.1x0.1 boxCollider2D that interacts with the inverters (that also have a very thin collider).
    if I make the colliders that interact with eachother small or thin, at certain speeds, very often (almost always) the collision is ignored. Then if I go through an inverter with enough speed, the gravity will still the same, because the collision was ignored.
    isn't there a way to tell unity that the child collider has OBVIOUSLY passed through the inverter collider?

    I tried with rigidbody collision detection set to continuous (also in the child small collider).
    I'm unable to find a workaround, or make unity not to skip those collisions at high speeds.


    IMPORTANT
    This is a class project and im forced to use a bunch of scripts given by the teacher (something similar to unity playgrounds but much worse) and the default unity components, i cant use custom ones.
    The methods i can use in this scripts related to collisions are: OnCollisionEnter2D, OnTriggerEnter2D, OnTriggerStay2D, OnTriggerExit2D, send and receive messages. And I can access public methods from other components.

    Please dont post alternatives that require aditional scripting.