Physics questions / Chase Cam

  1. When using box collision shape for character control. The physics are correct when it starts.

    Normal Physics



    I now call method CharacterControl.setViewDirection(), the model rotates correctly,

    but the physic box is never updated (doesn’t rotate at all).

    Box didnt rotate



    Which leads to this graphic artifact.

    Character’s hand goes inside building


  2. Another problem i noticed is that sinbad’s boots are bellow the ground by 0.1,

    the box is in the correct position, but the model’s boots are bellow the ground (by a little),

    any way to modify the model position without changing the box?





    [java]

    private void setupCharacter(Vector3f position)

    {

    playerModel = assetManager.loadModel(“Models/Sinbad/Sinbad.mesh.xml”);

    playerModel.scale(0.25f);

    rootNode.attachChild(playerModel);



    BoundingBox playerBox = NodeUtilities.getBoundingBox(playerModel);

    CollisionShape playerCapsule ;



    if (CAPTULE_CHARACTER_SHAPE)

    {

    playerCapsule = new CapsuleCollisionShape(playerBox.getXExtent(), playerBox.getYExtent()/2f, 1);

    }

    else

    {

    playerCapsule = new BoxCollisionShape(playerBox.getExtent(null));

    }



    playerPhysics = new CharacterControl(playerCapsule, 0.10f);

    playerModel.addControl(playerPhysics);

    playerPhysics.setPhysicsLocation(new Vector3f(position.x, playerBox.getYExtent()+position.y, position.z));

    getPhysicsSpace().add(playerPhysics);

    playerPhysics.setJumpSpeed(20);

    playerPhysics.setFallSpeed(30);

    playerPhysics.setGravity(30);

    }

    [/java]


  3. Note: if i use captule collision shape :

    a) problem 1 doesn’t happen because captule has the same size in x , z.

    b) problem 2 doesn’t happen.

    c) however if i use captule, then sinbad is fat and cannot pass through narrow places.

    this is because the hands increase the size of the captule in all dimensions.



    Can’t pass



    Lets see your suggestions.

The character doesn’t rotate. This is how it is.

For the box shape

1 - You can use control.setphysicsRotation() (maybe?)

2 - Add sinbad to a node move sinbad up and add the control to the node instead

1 Like

@normen:

The character doesn’t rotate. This is how it is

i tried to do spatial.rotate, this command is ignored, model doesn't rotate at all.

@Wezrule
1)
1 – You can use control.setphysicsRotation() (maybe?)


CharacterControl doesn't have that method.
should i use RigidBodyControl for my player instead a character control ?

If you want to rotate just the spatial use setViewDirection.

yes thats how i rotate the sinbad, with setViewDirection but the “physics box” doesn’t rotate with that command.

correct

yeh the CharacterControl has limits of its own, but i think it was a standard from bullet. My advice would be to do:



[java]

// keeps it always upright

control.setSleepingThresholds(0.0, 0.0);

control.setAngularFactor(0.0);[/java]



And then move it with physics forces (setLinearVelocity) and then change angular factor or something when you want it to rotate

1 Like

these methods are in rigid body class.

character control takes as input a Collision Shape, so it cant take a rigid body as input.

i will try to rewrite physics without character controls.

yeh its for the RigidBodyControl, but those methods will keep it upright (like the character control) but gives you more control

off the record, but i noticed that also the captule has the same position problem 2) as the cube,

sinbad flies by 0.1 if you use captule collision shape for the character control.