# How to access coordinates of objects in bullet physics (libGDX)?

I need to access the x, y and z coordinates of a bullet physics object. I'm assuming this is done via the transform matrix, but I have no idea which values mean what. There doesn't seem to be any information about it on the internet. How is this done? Is there a better was of doing it that I'm not aware of?

Note that this is only from reading the doc. I haven't actually tested anything of it.

For some reasons, it appears that Bullet Physics uses the term "origin" for "translation".

I guess that once you've found the transform matrix you're after (btTransform), you'll need to use the getTransform() method to retrieve the translation vector.

There seems to be complete doc of Bullet Physics used in libGDX here.

Also, with the little knowledge I have of Bullet Physics, I think the proper approach to have your objects updated is to use the concept of motion states. From what I remember, it is the mechanism used to link your model's world's position and orientation to the physics world simulated by Bullet Physics. You supply Bullet with a reference to your matrix via the motion state, so whenever bullet updates the world, it updates the matrix automatically so you don't have to do it yourself.

I'm not familiar with Java/libGDX, and the last time I used Bullet was long ago, so I'll link to the documentation I found about it.

• Well, this answer gave me a nudge in the right direction. Turns out there's a very easy way of accessing coords with getTranslate() that completely flew over my head. I'm going to write an answer in case anyone comes across this question looking for it. Sep 29 '18 at 21:28

To access the x, y and z coordinates of a physics object, use the following code. Obj in this case is an instance of the class RigidBody, and a Vector3 containing the coords is being returned.

obj.getWorldTransform().getTranslation(new Vector3(0, 0, 0))


The Vector3 here is simply where the coords are stored. Bullet doesn't want to give you direct access to the vectors it uses so you don't mess them up, so you have to supply it with one.