(Java and LWJGL expert here, but I only started using JME yesterday)
Hi,
I have successfully followed the collision tutorial. I now have a heightmap-generated world, with a player which can walk along and collide with.
However, when I attempt to add collision to a loaded OBJ model, I get the following error:
java.lang.ClassCastException: com.jme3.scene.Geometry cannot be cast to com.jme3.scene.Node
The error occurs when using this code:
CollisionShape planeShape =
CollisionShapeFactory.createMeshShape((Node) plane); <- Error happens here
RigidBodyControl planeLand = new RigidBodyControl(planeShape, 0);
plane.addControl(planeLand);
Obviously, plane
is not instanceof
node. But why? When I add terrain collision, I use the line CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) terrain);
without any issues. Both terrain and plane are of type Spatial.
To load the plane variable, I use the following code:
Spatial plane = assetManager.loadModel("Models/PlaneModel.obj");
And I am successfully able to render the plane.
I haven’t been able to solve this after about an hour of looking (and testing), so any help would be appreciated.
Thank you
Joe