Hi there guys
I’m creating a 3d topdown game (A RTS) and right now i’m still learning how to play with jmonkey.
I’ve created 2 classes, one named Minions and another named Obstacle, which represent minions and obstacles.
I also have a TerrainQuad with height that is my terrain.
I got the 2 Boxes deployed, I got one moving, but cant get collision working between em. Tried so many different ways but no one solved my problem:
Here’s my class Minion
public Node MinionNode;
private RigidBodyControl MinionObstacle;
Vector3f startPos;
Material material;
Boolean active = false;
Geometry geometria;
TerrainQuad terrain;
public Minion(AssetManager assetManager, TerrainQuad terrain) {
Box box = new Box(10, 10, 10);
geometria = new Geometry("Box", box);
material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
material.setColor("Color", ColorRGBA.Blue);
geometria.setMaterial(material);
geometria.setName("Caixinha");
this.terrain = terrain;
startPos = new Vector3f(-50f, terrain.getHeight(new Vector2f(-50.0f, -50.0f)), -50.0f);
MinionNode = new Node("MinionNode");
MinionNode.attachChild(geometria);
MinionNode.setLocalTranslation(startPos);
BoxCollisionShape MinionShape = new BoxCollisionShape(new Vector3f(10,10,10));
MinionObstacle = new RigidBodyControl(MinionShape, 0);
MinionNode.addControl(MinionObstacle);
}
My Obstacle class is exactly like this, I just change the names of variables.
On my main, I have:
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(true);
// Boneco e Obstáculo
boneco = new Minion(assetManager, terrain);
rootNode.attachChild(boneco.MinionNode);
bulletAppState.getPhysicsSpace().add(boneco.getMinionObstacle());
obstaculo = new Obstacle(assetManager, terrain);
rootNode.attachChild(obstaculo.ObstacleNode);
bulletAppState.getPhysicsSpace().add(obstaculo.getMinionObstacle());
What I’m missing? Is there any simple way to fix this? Later one I would import some models and replace boxes with models.
Thanks a lot for help!