CharacterControl always starts outside Box Collision Shape

Hello, I want to set up a box around the only section of my terrain that people will be able to access. I set up a box with dimension 1700,1700,1700 & the Location to 0,2000,0. Then I set my ‘player’ Character Control, which is a Capsule Shape to the physics location 0,2000,0, so the center of each CollisionShape should be in the same point, right? & the ‘player’ will be in the exact centre of the box. Well, my ‘player’ always starts off right outside the box. I think that the box must be pushing away the Character, but i’m not sure why. This is an extract of code:

Code:
BoxCollisionShape surroundingBox = new BoxCollisionShape(new Vector3f(1700,1700,1700));
 BoxShape = new RigidBodyControl(surroundingBox, 0);
 BoxShape.setPhysicsLocation(new Vector3f(1,2000,1));

        bulletAppState.getPhysicsSpace().add(BoxShape);
                CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(0.5f, 1.8f, 1);
        player3 = new CharacterControl(capsuleShape, 0.5f);
      player3.setJumpSpeed(17);
      player3.setFallSpeed(30);
      player3.setGravity(20);
                    player3.setPhysicsLocation(new Vector3f(0, 2000, 0));

        
        bulletAppState.getPhysicsSpace().add(player3);

Does anyone have a solution?

I don’t quite understand what your trying to do, but it looks like your creating a box with 1.7km width, height and depth, and trying to put a character inside this? that’s not allowed. Are you trying to emulate something like a fence to prevent the character from moving outside?

Yeh, thats exactly it. Why isn’t this allowed?

Cause a box is solid, try with a mesh.

1 Like

Would 4 quads work?

Theres a PlaneCollisionShape (the most efficient), but I haven’t used it before. As long as your objects aren’t moving too fast, it should work. I normally stick with boxes as you have to make sure that the object doesn’t go through before the next physics tick.

1 Like

Okay. I’m going to attempt an array of 4 quads, i’ll be back if it doesnt go to plan. Thanks.