W
W
WasTabon2020-10-05 14:14:28
Unity
WasTabon, 2020-10-05 14:14:28

Why are collisions not handled immediately?

5f7aff70a3d08162777833.png
5f7aff914a062891507786.png

private void OnCollisionExit2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "Ground")
        {
            playerMoving.isGrounded = false;
        }

        if (coll.gameObject.tag == "spike")
        {
            healthScript.health -= spike.damage;
        }
    }


Here, the player is the screen above, and the spike is the screen below, collisions occur only after a few milliseconds, for example, I go to the object, climb a little on it, then I fall and a collision occurs, and if you jump on top of it, then nothing will happen, you need to will move. The object by the way is a triangle with Polygon Collider 2D

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WasTabon, 2020-10-05
@WasTabon

Ahahaha, I didn't even notice that it was on Exit2D

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question