Hello, I am currently developing a game where you pick out your pieces before you play. Once they are picked out you will switch between them and move each piece and attack with each on your turn. If i want to control just one model at a time and have it collide-able with all my other models how would I go about this. Ive been trying to make a loop where when I change what piece I am moving the player control and the RigidBodyControl controller overlap and give me a unwanted effect while moving in 3d space.
if anyone has defined a way to move different pieces around with collision working please lend a hand.
eample:
[java]
Node EntityHolder;
Spatial Troop;
BulletAppState bulletAppState;
CharacterControl person;
RigidBodyControl player;
EntityHolder = new Node();
EntityHolder.setLocalTranslation(0, 0, 0);
/*
SETTEAMSpatials
*/
/*--TROOP--*/
Troop = assetManager.loadModel("Models/GreenFinishedModels/Troops/GreenStarSoldier.j3o");
mat.setTexture("DiffuseMap",
assetManager.loadTexture("Textures/GreenTroops/greenstarsoldier01.jpg"));
Troop.setMaterial(mat.clone());
Troop.setShadowMode(ShadowMode.CastAndReceive);
Troop.setLocalTranslation(-40, 0, 0);
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
EntityHolder.attachChild(Troop.clone());
rootNode.addChild(EntityHolder);
for (int i = 0; i < EntityHolder.getQuantity(); i++) {
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(EntityHolder.getChild(i));
player = new RigidBodyControl(sceneShape, 0);
EntityHolder.getChild(i).addControl(player);
bulletAppState.getPhysicsSpace().add(player);
}
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
person = new CharacterControl(capsuleShape, 0.05f);
person.setJumpSpeed(0);
person.setFallSpeed(0);
person.setGravity(0);
person.setPhysicsLocation(EntityHolder.getChild(Selected).getLocalTranslation());
bulletAppState.getPhysicsSpace().add(player);
[/java]
What I am wanting to do is have a army that cannot pass-through other pieces. but at the same time I want to be able to select individual pieces and move them. should I just keep them all RigidBody, and move them with custom code. I ask because when I change player control to a new piece the RigidBody controller and the player try to occupy the same space and it causes unwanted movement. What Should I do to be able to move all my units and keep collion detection and prevent intersections between units.
Have you taken a look at the canonball demo? The one that has you fire out cannonballs that bounce off things etc.
Can’t you just model your pieces in a similar way and then have the movement apply a force to them rather than just shooting them and letting inertia take its course?
thank you I will take a look into it. Right now my current situation is like playing a game of chess but the pieces are bought and the number of pieces change depending on what you buy since the pieces have different cost. when I am done you will be able to click on each piece and then control it. Ive been working on something for the past few hours. I think im on the right track but ill see if the canonball demo is going to push me forward. thank you.
I figured it out. Thank you. I added two controls to each model. Then when I accessed the Model I turned both off using Model.getControl(…Class).setEnabled(false);
then I turned the selected piece Character controller on and passed a walking vector to the physical Location to move it. and when I unselected the model I then shut both Controllers off again and turned on the RigidBody. works great now. Next thing to do is ray cast a front left(diagonal) and Right(diagonal) and start implementing object avoidance.