I’ve been testing out Jme3’s awesome physics engine for the past few days and It’s really amazing, especially the collisions. So I thought, I’m making an openworldish space game and would need the player to stay at origin to avoid floating point errors, but I’d like to have physics. In theory I would have everything in a node that moves in a negative vector to what the player movement would be and that’s fine. But I think a problem would appear with handling collisions. If I gave the player a mass of 0 and the world with the player’s mass then the player wouldn’t rotate when coliding with the world, but the world would and that’s less than optimal i’d say. The problem is I’d like to have split collision reponse: the world bounces away and the player rotates like it hit an obsticle. I’m not sure what would be the best way to go doing this so I’m asking what you guys think. Any ideas?
Also I don’t think physics can handle double layered objects like: the world is one node with a physicscontroller and it’s children would be also physics objects with controllers but would behave with physics relative to the world node’s origin. Then again I haven’t tried this last thing yet…
Just use physics the normal way but zero-out the physics locations when the player moves far. You don’t need to use PhysicsControls, you can use the base physics objects and apply the locations based on your “inverted” positioning.
@normen Alright so I’ve tried to get this figured out today, but it seems that if I actually wanted to make this work i’d need to change the applyTransform() method in RigidBodyMotionState class. I figured I’d make my own physicscontrol to handle the positioning and have looked at your code for the RigidBodyControl. If i get this correctly the update() method is the thing that sets the spatial’s position it appears to only call the motionstate’s apply method. To refresh your memory:
public void update(float tpf) {
if (enabled && spatial != null) {
if (isKinematic() && kinematicSpatial) {
super.setPhysicsLocation(getSpatialTranslation());
super.setPhysicsRotation(getSpatialRotation());
} else {
getMotionState().applyTransform(spatial);
}
}
}
PhysicsRigidBody only keeps a link to the motionstate and has a getter for it, so I guess there isn’t much that I can do with that is there? Or is the process of applying the position as simple as setLocalTranslation/Rotation? What’s the physicsLocationDirty thing about?
Nah, you can either use getPhysicsLocation/Rotation directly or use getWorldLocation/Rotation of the motionState, only difference between the two is that the MotionState is interpolated between actual physics ticks based on how often the physics update is called.