Box2D: How to detect which side of a polygon gets collision -


A small rectangle is tilted towards a large rectangle. I want to know whether it is in "rectangle" or "upper" Kills big rectangle

I would also like to know that the small polygon is going to rest on its side, or below I'm imagining that it will find Getangle () on the basis of the body, how it is oriented, but I want to hear what a better way is.

Thank you

You can make several fixtures by "colliding with your object" Can create. Use polygon or square shape for main stability. Then attach several zero mass fixtures around the perimeter as "sensor" and using attachments in all of them to determine who hit a collision.

This image shows the original idea:

Enter image details here

By doing this, Box2D will handle all the work when dealing with the angle you were affected or who was affected first

This technique is only used for four sides of the box For no you can use it for any body, where collision is required, depending on where you have collisions, "Require.

Note: You want to constantly detect conflicts and / or set your small box to be a "bullet", so that it can not tunnel through one of your sensors. Or actually make sensors larger (more detail in the size of the main goal). Or you can do the steps of simulation (small fixed time) so that the distance travels during simulation is much less than the width of the contact fixtures on your side. The goal of any of these ideas is to avoid "tunnel".

If you do not use sensor approach, then you can do geometry and velocity vectors and rotational angles (at the time) before the effect of joining for both bodies), but this It is very painful.

Was it helpful?

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -