Moving the jBullet collision body to with the player object
- by Kenneth Bray
I am trying to update the location of the rigid body for a player class, as my player moves around I would like the collision body to also move with the player object (currently represented as a cube). Below is my current update method for when I want to update the xyz coords, but I am pretty sure I am not able to update the origin coords? :
public void Update(float pX, float pY, float pZ) {
posX = pX;
posY = pY;
posZ = pZ;
//update the playerCube transform for the rigid body
cubeTransform.origin.x = posX;
cubeTransform.origin.y = posY;
cubeTransform.origin.z = posZ;
cubeRigidBody.getMotionState().setWorldTransform(cubeTransform);
processTransformMatrix(cubeTransform);
}
I do not have rotation updated, as I do not actually want/need the player body to rotate at all currently. However, in the final game this will me put in place.