Search Unity

Test 2D Collision Immediately

Discussion in 'Physics' started by Koval331, Nov 1, 2019.

  1. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    Hello! I want to be able to create / move a 2D collider (box collider) and test its collision data immediately, without waiting for Unity Physics to run.

    p.s. I need to move collider in multiple places per scene in one frame and test collision in those multiple places.

    Thanks in advance!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,473
    Where does this "collision data" come from if the physics simulation isn't run? What's supposed to be calculating it? :)

    Anyway, this is what queries are for, no need to use colliders. Physics2D.OverlapBox for instance. You can query the physics scene in various ways asking questions like what overlaps this area or if I sweep this shape through this space, what are the contacts etc. If you're modifying colliders within the scene then you're changing it and to get an update you need to (obviously) run the simulation.