Search Unity

Ignore hitboxs for a small amount of time

Discussion in '2D' started by unity_cMXCJt9KI6zOpw, Jul 26, 2019.

  1. unity_cMXCJt9KI6zOpw

    unity_cMXCJt9KI6zOpw

    Joined:
    Jul 23, 2019
    Posts:
    3
    hey i was wondering how to make it so when my sprite 1 jumps on sprite 2 it disables the hit box. I can't make it so they just don't collide because i need them to collide in other situations. this is my code

    void legs()
    //same as void update
    {
    if (Head == true)
    //if touching hitbox
    {

    gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 1f), ForceMode2D.Impulse);
    //this is where the hit box would be disabled
    }

    }