Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

ZoomBox
 Share

Recommended Posts

Hello !

 

I would like to know how can I get the bounds from a body ?

I'm using Physics.P2 and I can't figure out how to get them.

 

On top of that, I would like to get the Width and Height of a body (but coordinates would be nice too).

 

Thank you in advance for your answers. :)

Link to comment
Share on other sites

Those ideas are great, thank you.

But I was wondering if there was a way to do it in every cases: I have multiple shapes (rectangles and polygons) and I would like to be able to get each width of bodies.

For example: I have two sprites with their bodies (rectangular body or polygon and maybe a circle), and I want to be able to stick them (the bodies) one on top of each other precisely.

So your solutions could work in some cases but not in every cases (I will still try them monday).

I hope someone could give me the answer.

Link to comment
Share on other sites

Hey.

Thank you for your answer.

I found interesting things in body.data.vectices BUT there is a big problem: For those coordinates to be OK, I have to multiply them by 20. I don't know why, I haven't resize anything.

 

I will see what happen here.

Link to comment
Share on other sites

It works great with the body.data.shapes[0].verctices but I can't manage to find why I have to multiply each value by 20.

My bodies are rescaled by 0.3 not by 1/20 (0.05)... I don't understand.

 

P2 (like most physics systems) uses meters for distances and coordinates, not pixels. So every time a value is given to, or extracted from p2 it is converted from meters to pixels using a value of 20px/m. This is regardless of your object scale.

 

Edit: Also worth adding that physics world coordinates are essentially the opposite of screen coordinates, i.e. 0x 0y isn't the top left as far as p2 is concerned.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...