I'm trying to get the position of a static body in JBox2D, how do I do that?
1 Answer
\$\begingroup\$
\$\endgroup\$
3
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
-
\$\begingroup\$ thanx alot ...but its still not giving me the body's current position \$\endgroup\$ 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\$– HouseCommented 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\$ Commented Jan 6, 2014 at 17:35