Hi, I've this problem: it's a ball net game where the server compute the physics and sent to clients the current position of the ball.
The ball on server is a DynamicPhysicsNode and when it collide it makes sound. On the client I must make the ball as StaticPhysicsNode otherwise it conflict with the position set by server and ball become fuzzy.
With this StaticPhysicsNode I've seen that contatCallback are not detected and I cannot play sounds during collision.
What can I do?..
ContactCallback floorCollision = new ContactCallback() {
public boolean adjustContact(PendingContact c) {
System.out.println(c.getNode1().getName());
System.out.println(c.getNode2().getName());
if ((c.getNode1().getName().equals("floor") &&
c.getNode2().getName().equals("ball")) ||
(c.getNode1().getName().equals("ball") &&
c.getNode2().getName().equals("floor"))) {
// play sound
return true;
}
return false;
}
};
physicsSpace.getContactCallbacks().add(floorCollision);
The nodes that collides are StaticPhysicsNode with setIsCollidable(true) and setActive(true).
the System.out.println... are never execute!
maybe the 2 nodes cannot collide becouse they are Static, so how can I do if I would that my ball on client make ONLY sound when collide (and not react dinamically).
p.s.: is correct to send always position of ball via network! or there's a batter way?? thanks