box2d – Solution to examine overlaps of a collider2d that is not set to “is set off” in Unity

box2d – Solution to examine overlaps of a collider2d that is not set to “is set off” in Unity

[ad_1]

I’ve a system the place physics2d objects are spawned and I have to know once they spawn outdoors of a area outlined by a field collider set to “is Set off”.

Utilizing onTriggerEnter and onTriggerExit to know if an object exits / re-enters the bounds (with another situations figuring out whether or not to kill the item when it exits the bounds). That stuff works positive.

Nevertheless I can not detect when an object spawns outdoors of the collider (which I wish to permit, however simply know when it occurs).

I attempted the next within the Begin methodology of the spawned object:

Listing<Collider2D> outcomes = new Listing<Collider2D>();
_boundsCollider.OverlapCollider(new ContactFilter2D(), outcomes);
bool spawned_outside = !outcomes.Incorporates(_thisCollider);

Nevertheless on the time that methodology runs, the booundsCollider does not register it. Subsequent frames it should, however that is too late.

OverlapCollder cannot be run on the collider for the spawned object because it is not set as a set off.

Is there any means I can question the spawned object’s personal collider to find out whether it is in touch with the bounds collider?

Thanks!

PS I can not trivially simply reference the coords of the item and examine in the event that they’re out of bounds as a result of the bounds collider will transfer, and I wish to know with precision wether only a nook is overlapping or no matter so I would want one thing that quantities to my very own easy collision system

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply