Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to check if ball go through basket?

Discussion in '2D' started by Micheno_77, Apr 10, 2021.

  1. Micheno_77

    Micheno_77

    Joined:
    Mar 28, 2021
    Posts:
    3
    Hi, I'm making 2D basketball game and I stuck at the problem. How can I check if the ball go through the basket?
     
  2. BenniKo

    BenniKo

    Joined:
    Mar 24, 2015
    Posts:
    100
    Probably not the best solution but the first one that comes to my mind:
    Add a collider at the top of the basket and one at the bottom.
    The ball has to first trigger the top one and then (within a certain timeframe) trigger the bottom one.
     
  3. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,068
    One trigger should be enough.
    You check the direction of body velocity during on enter and on exit.
    This will let you determine if ball not entered from the bottom.
     
    BenniKo likes this.
  4. Micheno_77

    Micheno_77

    Joined:
    Mar 28, 2021
    Posts:
    3
    thanks(⌐■_■)