At first some Code:
public ManagerObjectLocked(TerrainBlock tb_new) {
this.lock();
tb = tb_new;
//test
listGegner = new LinkedList<GameObject>();
testObj.setLocalTranslation(new Vector3f(200,1000,200));
this.attachChild(testObj);
listGegner.add(testObj);
testObj.updateModelBound();
testObj.updateWorldBound();
testObj2.setLocalTranslation(new Vector3f(200,1000,190));
this.attachChild(testObj2);
listGegner.add(testObj2);
testObj2.updateModelBound();
testObj2.updateWorldBound();
}
In GameObject class:
public void activate() {
if(isHit) {
System.out.print("hit");
if(vHP > 0) {
vHP -= 10;
System.out.print(": arrgh");
}
else {
this.getLocalTranslation().z += 5f;
vHP = 50;
}
System.out.println();
isHit = false;
}
//Move from end to end
if(move) {
this.getLocalTranslation().x += 0.05f;
if(this.getLocalTranslation().x > 249)
move = false;
}
else {
//this.getLocalTranslation().x -= 0.05f;
if(this.getLocalTranslation().x < 1)
move = true;
}
}
And the "shot" in main update(tpf):
//Mouse input
shotTime += interpolation;
if(MouseInput.get().isButtonDown(0) && shotTime > 0.2f) {
System.out.println("*peng");
shotTime = 0f;
//Testshot
Ray ray = new Ray(cam.getLocation(), cam.getDirection()); // camera direction is already normalized
PickResults results = new BoundingPickResults();
results.setCheckDistance(true);
scene.findPick(ray, results);
if(results.getNumber() > 0) {
//Only hit first item (last in results)
Node tmpNode = results.getPickData(results.getNumber()-1).getTargetMesh().getParentGeom().getParent();
if(tmpNode.getName().startsWith("Obj")) {
GameObject tmpObj = (GameObject)tmpNode;
tmpObj.isHit = true;
}
}
results.clear();
}
So as you can see I lock the Manager (it extends Node). And it is the parent of the two testObj's. Without lock() I can hit them and they move like I want it. But when I start the code above...
1) ...I get no PickResults. And have no idea about the reason. As you can see I tried to update the bounds.
2) ...the GameObject's are still moving. Or I am wrong that they should not move?
Hint to myself:
If they stop moving I will find them in the air.