JME3 Question

Hello, I Have a few Qs about JME3. I recently started to use it instead of JME2 and I have been having LOTS of trouble with the physics!  I have a racetrack model, and a custom camera node attached to a Physics Vehicle Node and that works fine and dandy, but the track, not so much. how would I generate a custom collision shape for my racetrack?



Genius Games

Like this:


Spatial raceTrack=loadTrack();
//important - shapes do not scale with the Node due to multi-use, set scale before creating collision shape!
raceTrack.setLocalScale(desiredScale);
CollisionShape shape=CollisionShapeFactory.createMeshShape(raceTrack);
PhysicsNode trackPhysicsNode=new PhysicsNode(raceTrack,shape,0);
//important - rotate/place the physicsNode to the desired location, not the child!
trackPhysicsNode.setLocalTranslation(desiredLocation);
trackPhysicsNode.setLocalRotation(desiredRotation);
getRootNode().attachChild(trackPhysicsNode);
trackPhysicsNode.updateGeometricState();
getPhysicsSpace().add(trackPhysicsNode);


Cheers,
Normen

Thanks a LOT! :smiley:

ACK  more problems, I tested it out and my vehicle bounces all over the place once I start driving!

So I guess you configured it wrong, theres some posts about the vehicle, might be your wheels dont touch the ground or you configured mass and damping wrong.



Hope this helps,

Normen

alright, I have changed the theme of my game. Instead of a car racing game it is now podracing, so I need a way to make my podracer float above the track, I already have figured out how to make it float and almost perfected it and I can make it float higher on command and lower too, but I need to know how high the track is underneath the pod of my racer. I can guess that it has ray picking involved?

you can shoot a pickray down and get the location of the intersection and then subtract it from the players location and take the length which will be equal to the total distance

I made the vehicle test easier tweakable and added a debug shape for the car suspension, maybe this helps getting your vehicles right.