My CharacterController won't fall
-
I have a CharacterController, gravity is -9.18 but it just doesn't want to fall.
My code:import QtQuick import QtQuick3D import QtQuick3D.Helpers import QtQuick3D.Physics Window { id: window width: 1920 height: 1080 visible: true title: "qt quick 3d" visibility: Window.FullScreen property real moveSpeed: 4 Timer { interval: 16 running: true repeat: true onTriggered: { let dir = control.wasdVector(player.eulerRotation.y) player.movement = Qt.vector3d( dir.x * moveSpeed, player.movement.y, dir.z * moveSpeed ) } } View3D { anchors.fill: parent PhysicsWorld { id: physWorld gravity: Qt.vector3d(0, -100, 0) running: true } environment: SceneEnvironment { lightProbe: Texture { source: "sunny_rose_garden_2k.hdr" } backgroundMode: SceneEnvironment.SkyBox } CharacterController { id: player position: Qt.vector3d(0, 20, 0) gravity: physWorld.gravity simulationEnabled: true collisionShapes: CapsuleShape { height: 1.8 diameter: 0.4 } PerspectiveCamera { id: cam y: 1.8 } } Model { source: "#Cube" id: floor materials: PrincipledMaterial { baseColor: "grey" metalness: 0.0 roughness: 0.5 } scale: Qt.vector3d(1, 0.01, 1) StaticRigidBody { collisionShapes: BoxShape {} } } } /*WasdController { controlledObject: cam }*/ Timer { interval: 500 running: true repeat: true onTriggered: { console.log( "pos.y =", player.position.y, "movement =", player.movement, "gravity =", player.gravity ) } } MouseArea { anchors.fill: parent hoverEnabled: true focus: true acceptedButtons: Qt.AllButtons cursorShape: Qt.BlankCursor property real yaw: 0 property real pitch: 0 property real sensitivity: 0.2 property real lastX: 0 property real lastY: 0 onPositionChanged: (m) => { // вычисляем дельту относительно центра let dx = m.x - width/2 let dy = m.y - height/2 yaw -= dx * sensitivity pitch -= dy * sensitivity pitch = Math.max(-80, Math.min(80, pitch)) cam.eulerRotation = Qt.vector3d(pitch, 0, 0) player.eulerRotation = Qt.vector3d(0, yaw, 0) // возвращаем мышь в центр control.setMousePos(width/2, height/2) lastX = width/2 lastY = height/2 } Component.onCompleted: { forceActiveFocus() control.setMousePos(width/2, height/2) } Keys.onPressed: (event) => { if(event.key === Qt.Key_W) control.onWPressed() if(event.key === Qt.Key_A) control.onAPressed() if(event.key === Qt.Key_S) control.onSPressed() if(event.key === Qt.Key_D) control.onDPressed() if(event.key === Qt.Key_Space) control.onSpacePressed() if(event.key === Qt.Key_Control) control.onCtrlPressed() if(event.key === Qt.Key_Shift) control.onShiftPressed() } Keys.onReleased: (event) => { if(event.key === Qt.Key_W) control.onWReleased() if(event.key === Qt.Key_A) control.onAReleased() if(event.key === Qt.Key_S) control.onSReleased() if(event.key === Qt.Key_D) control.onDReleased() if(event.key === Qt.Key_Space) control.onSpaceReleased() if(event.key === Qt.Key_Control) control.onCtrlReleased() if(event.key === Qt.Key_Shift) control.onShiftReleased() } } }The c++ function
wasdVectorworks as intended, so where's the problem?P.S. sorry if the code is messy