Hey,
it’s all in the title. I mean, are the collisions checked also in the CollisionShape or only at fronteer ?
Thx !
They are hollow but you can also bump into the walls from inside, yeah. You can find out such stuff by simply creating a test case btw, also flexes your jme3 app writing skills
It’s weird then 'cause I use a box which contains my game platform. On this platform I make a ball rolling on (pretty much like in a flipper). I add the box in case my ball falls off the platform so it can respawn on the platform when it touches the box.
But I have a weird bug, as soon as the ball spawns, it seems that the collision (with the surrounding box) is detected and it makes my ball respawn. And of course, as soon as it respawns, the collision is detected again and it makes my ball respawn again, and all this in loop.
My guess is that even in the box, the collision is detected which is weird as you told me that this was supposed to be hollow. Is there a way to avoid this ?
I guess your box is at 0/0/0 when you add it to the physics space.
Yes… but I tested with other coordinates too and had the same bug.
When you go physicsSpace.add() and then setPhysicsLocation() it makes no difference to what you set the location, the initial location is the one when added to the physics space.
I’m not sure of what you’re saying but I don’t think I’m doing such a thing on initiating my box. Here is my code :
[java] protected void createDeathTrap(Node platformNode, AssetManager assetManager, BulletAppState bulletAppState) {
deathtrap = new Box(length, width, height);
deathtrapGeometry = new Geometry(name, deathtrap);
deathtrapMaterial = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);
deathtrapCollisionShape = new BoxCollisionShape(new Vector3f(length, width, height));
deathtrapPhysics = new RigidBodyControl(deathtrapCollisionShape, 0f);
deathtrapNode = new Node(name + “Node”);
deathtrapMaterial.setColor(“m_Color”, ColorRGBA.Cyan);
deathtrapGeometry.setMaterial(deathtrapMaterial);
deathtrapGeometry.addControl(deathtrapPhysics);
deathtrapPhysics.setKinematic(true);
bulletAppState.getPhysicsSpace().add(deathtrapPhysics);
bulletAppState.getPhysicsSpace().addCollisionListener(this);
deathtrapNode.attachChild(deathtrapGeometry);
deathtrapNode.setLocalTranslation(this.getLocation());
platformNode.attachChild(deathtrapNode);
}[/java]
I give directly the coordinates where I want to setup my box as parameters when I call this method.
Btw, do you mean that when my collider hit the center of the collision shape, a collision is detected ?
Yes you do. You first add the body to the physics space and then set its location. First set the location to the spatial, then add the rigidbody control, then add it to the physics space, then set kinematic mode.
I’ve tried this :
[java] protected void createDeathTrap(Node platformNode, AssetManager assetManager, BulletAppState bulletAppState) {
deathtrap = new Box(length, width, height);
deathtrapGeometry = new Geometry(name, deathtrap);
deathtrapMaterial = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);
deathtrapNode = new Node(name + “Node”);
deathtrapMaterial.setColor(“m_Color”, ColorRGBA.Cyan);
deathtrapGeometry.setMaterial(deathtrapMaterial);
deathtrapNode.attachChild(deathtrapGeometry);
deathtrapNode.setLocalTranslation(this.getLocation());
deathtrapCollisionShape = new BoxCollisionShape(new Vector3f(length, width, height));
deathtrapPhysics = new RigidBodyControl(deathtrapCollisionShape, 0f);
deathtrapGeometry.addControl(deathtrapPhysics);
bulletAppState.getPhysicsSpace().add(deathtrapPhysics);
bulletAppState.getPhysicsSpace().addCollisionListener(this);
deathtrapPhysics.setKinematic(true);
platformNode.attachChild(deathtrapNode);
}[/java]
But it’s still bugging the same way.