I am trying to let a character walk on a box using the physics space.
I dont really know how to adjust the capsulecollisionshape to the model. I am using the ninja model and its feet are in the center of the capsule I created. Do I need a model with 0,0,0 in its center or is there a way to adjust the collisionshape?
The CapsuleCollisionShape falls onto the box and then slowly starts to sink into it, if I dont move it. I guess I set something up in a wrong way, cause the collision only seems to work for the sides of the triangles. At least it looks like that when I enable the debug mode. I just cant figure out whats wrong.
I checked your testclass and its indeed realy strange. I looked at the TestQ3 in the bullet examples again and I can see this behavior in parts of the level too.
Maybe something is broken in the CharacterControl?! I didnt use CharacterControl since a couple of month now. Before that it worked fine.
I’ve heard other users over the past few months encountering the characterControl slipping through the floor problem. The suggested solution usually is to have a more dense mesh for the floor object. The box face that you’re using for the floor is 100x100 units, which is quite large. I’m guessing the reason it’s suggested is because the physics calculations get a bit confused when the collision object has it’s points so spread apart. Anyway, it’s an easy thing to try.
Another thing you could mess with is the actual capsule shape’s dimensions. The capsule you’re using is barely a pill shape at all with a length of 1 and a rad of 2 (5 units in all tall, I think).
As far as the collision shape being placed at the feet of the ninja model, any model with a characterControl always has it’s center repositioned to the center of the characterControl’s physics position. I don’t know much about the ninja model myself, but you can offset the center of the model using another node. If you search the forum a bit, you’ll probably find another user who did this fairly recently.
I seem to be having the exact same problem, tho on a much smaller scale. I created a 5x5 floor, and my player (a simple cube) still falls into the floor. Tho it looks like the engine is trying to fix itself - meaning the player pops out of the floor and starts sinking back in. The only thing different in my code is using CylinderCollisionShape instead of a capsule and using a simple box for a player instead of a mesh. I’m using todays build, tho not working with jme ide.
It’s actually my first dip into 3d programming so I’m bound to get stuff wrong, but seeing this thread made me think that there’s more to this problem.
public Floor moveTile(float x, float y, float z) {
this.control.setPhysicsLocation(new Vector3f(x, y, z));
return this;
}
public Spatial getSpatial() {
return geo;
}
}
[/java]
Player.java
[java]
public class Player implements MapTile {
private Spatial node;
private CollisionShape cShape;
private CharacterControl control;
public static Player create(AssetManager assetManager) {
Player o = new Player();
Box b = new Box(0.4f, 0.5f, 0.4f);
o.node = new Geometry(“Player”, b);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, ColorRGBA.Red);
o.node.setMaterial(mat);
o.cShape = new CylinderCollisionShape(new Vector3f(0.4f, 0.5f, 0.4f), 1);
o.control = new CharacterControl(o.cShape, 0.01f);
o.node.addControl(o.control);
return o;
}
public Spatial getSpatial() {
return node;
}
public CharacterControl getControl() {
return control;
}
public Player moveTile(float x, float y, float z) {
this.control.setPhysicsLocation(new Vector3f(x, y, z));
return this;
}
}
[/java]
If i replace CharacterControl with RigidBodyControl everything is alright - the cube doesn’t fall through the floor.
Sticking with CharacterControl - the suggestions tehflah seem to solve the problem only partially. For example making the CollisionCylinder bigger only lessens the effect. The player still seems to sink into the floor and pop out of it, just not completely. Only about half a unit. Strange.
So - what’s the best way to deal with this problem?
Should I try to get CharacterControl to work or can I use some other control for the player? What are the advantages of using either?
What’s the usual/best scale for working with opengl? (is it ok if my tiles are 1 world unit large? Or should they be bigger?)
Yeah, I got the message about large boxes from tehflahs post
But this really boils down to what is recommended scale for working here? (meaning the height of an ‘normal’ user-visible object) Is it 1 world unit? 10? I’m trying to build a basis for a tile-based game, so i’ll be working with mostly square-based objects. So how big (world unit wise) should one 3d tile be?
I tried fiddling with the stepHeight but i still get the same thing (big values make the player fall through completely, small result in him sinking in and popping back continuously). I understand this value should probably be relative to how big my other objects are. But the docs or tutorials don’t really say anything about this.