Hi Monkeys,
I’m currently facing a little problem concerning Physics. And ask for your help .
Here is the situation :
I have one GhostObject and a BetterCharacterControl and I want to get a rising edge when the character enter the area and reset it when he leave it. So I implemented it so :
public class BoxTriggerListener extends GhostControl {
private final TriggerType type;
private boolean actionDone = false;
public BoxTriggerListener(Node n) {
super();
BoundingBox box = (BoundingBox) n.getWorldBound();
BoxCollisionShape b = (new BoxCollisionShape(new Vector3f(box.getXExtent(), box.getYExtent(), box.getZExtent())));
this.setCollisionShape(b);
}
@Override
public void update(float tpf) {
super.update(tpf);
if (this.getOverlappingCount() > 0) {
if (!actionDone) {
System.out.println("Event_"+FastMath.nextRandomInt());
}
actionDone = true;
} else if (this.getOverlappingCount() == 0) {
actionDone = false;
}
}
}
But more than half on the time 2 event are fired when the character enter the ghost area. And I can’t find the issue because in debug the behavior seems to be ok. (I cleaned up the code)