0
\$\begingroup\$

I'm trying to get the position of a static body in JBox2D, how do I do that?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I haven't used JBox2D, but I think this is accurate. I looked at the source for the project and learned a lot (and you can too). Primarily that body contains a Transform, and that the Transform contains the position.

Since all those variables are public, it's likely you'll be able to access the position from:

myStaticBody.m_xf.p

\$\endgroup\$
3
  • \$\begingroup\$ thanx alot ...but its still not giving me the body's current position \$\endgroup\$
    – user40647
    Commented Jan 5, 2014 at 18:50
  • \$\begingroup\$ You're going to need to add more details to your question. What have you tried already, what about it isn't working? Are you getting a position, but it's not the correct one? Details needed. \$\endgroup\$
    – House
    Commented Jan 5, 2014 at 18:51
  • \$\begingroup\$ Vec2 position = body.getPosition(); System.out.println(position.x);i have tried that but i only get one position which is its original position not its current position \$\endgroup\$
    – user40647
    Commented Jan 6, 2014 at 17:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .