Coyote
Coyote

Reputation: 2524

Solve collisions outside of the normal physics cycle

Is there a way to test and resolve collisions outside of the usual collision system?

There is a situation where I want most of the game objects to collide using the basic filters system unity provides.

But a very special group of objects (within 4 different layers) will behave differently and collide in some situations differently.

I will add child objects with circular triggers to serve as the broad phase, then I would like to call the engine's collision resolution only if the objects are supposed to collide.

How should I proceed to trigger the collision resolution manually?

Upvotes: 0

Views: 1236

Answers (1)

game development germ
game development germ

Reputation: 1334

You can use Physics2D.BoxCast, Physics2D.CircleCast, Physics2D.OverlapArea or Physics2D.OverlapCircle to check collisions outside of physics' simulation routine.

You may resolve collisions based on data received from methods above. AFAIK Physics2D is adopted Box2D, which is open-source. So you may find solution for coliisions in its source code.

Upvotes: 2

Related Questions