ThirdPersonHandler and DynamicPhysicsNode

hi,



is it possible to attache a DynamicPhysicsNode to a ThirdPersonHandler so my 'avatar' would have physical behavior?



I tried to, but without success. here is my code:



private void buildPlayer() {
        Box b = new Box("box", new Vector3f(), 1, 1, 1);
        b.setModelBound(new BoundingBox());
        b.updateModelBound();
        Spatial playerNode = new Node("char node");
        ((Node) playerNode).attachChild(b);
        playerNode.updateWorldBound();

        player = getPhysicsSpace()
        .createDynamicNode();
        rootNode.attachChild(player);
        ((DynamicPhysicsNode) player).attachChild(playerNode);
        ((DynamicPhysicsNode) player).generatePhysicsGeometry();

    }

    private void setupChaseCamera() {
        Vector3f targetOffset = new Vector3f();
        targetOffset.y = agl * 1.5f;
        chaser = new ChaseCamera(cam, player);
        chaser.setTargetOffset(targetOffset);
    }

    private void setupInput() {
        HashMap<String, Object> handlerProps = new HashMap<String, Object>();
        handlerProps.put(ThirdPersonHandler.PROP_DOGRADUAL, "true");
        handlerProps.put(ThirdPersonHandler.PROP_TURNSPEED, ""
                + (1.0f * FastMath.PI));
        handlerProps.put(ThirdPersonHandler.PROP_LOCKBACKWARDS, "false");
        handlerProps.put(ThirdPersonHandler.PROP_CAMERAALIGNEDMOVE, "true");
        input = new ThirdPersonHandler(player, cam, handlerProps);
        input.setActionSpeed(20f);
    }



any hint?

should i use StaticPhysicsNode instead?

In the tutorials there is a simple lesson with a very basic avatar (not sure… Lesson 8 ?). ThirdPersonHandler is not the best thing for controlling a physical avatar, as it changes the position directly. For correct physical behavior you need to apply forces or use powered joints instead.