Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Smooth character movement
Forum Updated to NodeBB v4.3 + New Features

Smooth character movement

Scheduled Pinned Locked Moved Unsolved Game Development
spritemove
27 Posts 6 Posters 15.2k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • johngodJ johngod

    Thank you all for this usefull post. I have a qml game, I'm using a Timer that is triggered with a bool variable that is binded to keys pressed and release, at a fixed speed of 1000/60.
    The animation looks smooth in some cases in but in other cases it does not. So the correct aproach should be not to use a Timer, but trigger the animations with vsync, right? Is it possible to do this in qml? Also it seems qml does not 'respect' the timer interval, sometimes I get higher frame rates, maybe I have something else mess up. Besides Timers, I am using NumberAnimations, I think that will mess the Timer interval ? I have done some testings using Timers, and qml render.stats, in my laptop with a Nvidia GTX1050 TI, I get:

    • windows with native screen, animations are ok, smooth, renderstats shows aprox. 60fps
    • windows with gaming monitor of 165Hz, animations are not smooth, renderstats shows aprox. 77fps
    • linux mint, native screen, animations are ok, smooth, renderstats shows aprox. 60fps
    • linux mint, gaming monitor of 165Hz, animations are ok, smooth, renderstats shows aprox. 120fps
    • macbook air, native screen, animations are ok, smooth, renderstats shows aprox. 60fps
    • macbook air, gaming monitor, animations not smooth, renderstats shows aprox. 45fps, maybe because of the hdmi cable with a display port adapter, that mess the performance
    • iPhone 7, animations are ok, smooth, renderstats shows aprox. 60fps
    • android phone, animations are ok, smooth, renderstats shows aprox. 60fps
      Is there any cross plataform way of checking the vsinc and triger it to render the game loop ?
      By the way, I have builds of my game for Windows, Mac, Linux (only binary) here https://drive.google.com/drive/folders/1JWrkcLyNfIZSmleJOJRkunM8mZUiIxDG?usp=sharing
      also the code, if anybody wants to check it https://bitbucket.org/joaodeusmorgado/davidgalacticadventures/src/master/
      Thanks
      printescreen.png
    8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by 8Observer8
    #21

    @johngod your demo doesn't work on my laptop with Window 10. It shows a white scene:

    08ac1aab-7e8e-45c0-a7aa-215090b64795-image.png

    johngodJ 1 Reply Last reply
    0
    • 8Observer88 8Observer8

      @johngod your demo doesn't work on my laptop with Window 10. It shows a white scene:

      08ac1aab-7e8e-45c0-a7aa-215090b64795-image.png

      johngodJ Offline
      johngodJ Offline
      johngod
      wrote on last edited by
      #22

      @8Observer8 Are you compiling from git or running the zip file ? If compiling the source do you have any errors and what version of Qt are you using ? (you will need Qt6.2 iirc) What's your gpu ?

      8Observer88 1 Reply Last reply
      0
      • johngodJ johngod

        @8Observer8 Are you compiling from git or running the zip file ? If compiling the source do you have any errors and what version of Qt are you using ? (you will need Qt6.2 iirc) What's your gpu ?

        8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by 8Observer8
        #23

        @johngod I downloaded a zip with EXE. I have: Asus K53SV; 8 GB RAM, i3 2.2 GHertz (2 cores); Intel HD Graphics 3000; Nvidia GeForce GT 540M (1 GB); Windows 10

        It is because my laptop run your app with integrated video card (Intel HD Graphics 3000 that uses OpenGL 3.1). I can run it with the second one:

        860d0a37-6c21-4e05-8586-680e67ed90ab-image.png

        I click on the space ship (on Earth, and on ship again) in the top left corner:

        928a734f-db79-4af2-8a56-14a0fe21e230-image.png

        and see a black screen only with interrupted music:

        78dbaa65-a30a-4d59-b0c7-4a24782886fe-image.png

        johngodJ 1 Reply Last reply
        0
        • 8Observer88 8Observer8

          @johngod I downloaded a zip with EXE. I have: Asus K53SV; 8 GB RAM, i3 2.2 GHertz (2 cores); Intel HD Graphics 3000; Nvidia GeForce GT 540M (1 GB); Windows 10

          It is because my laptop run your app with integrated video card (Intel HD Graphics 3000 that uses OpenGL 3.1). I can run it with the second one:

          860d0a37-6c21-4e05-8586-680e67ed90ab-image.png

          I click on the space ship (on Earth, and on ship again) in the top left corner:

          928a734f-db79-4af2-8a56-14a0fe21e230-image.png

          and see a black screen only with interrupted music:

          78dbaa65-a30a-4d59-b0c7-4a24782886fe-image.png

          johngodJ Offline
          johngodJ Offline
          johngod
          wrote on last edited by
          #24

          @8Observer8 I have no clue sorry, but that is a very old demo. I just made a new build https://drive.google.com/file/d/1pdyL4lq2XpOcpv0ePxB57SPE30rBvsgw/view?usp=sharing maybe this will work. It it still does not work, maybe you can compile from source and see if there are any errors. Thank you for the interest in my game.

          8Observer88 1 Reply Last reply
          0
          • johngodJ johngod

            @8Observer8 I have no clue sorry, but that is a very old demo. I just made a new build https://drive.google.com/file/d/1pdyL4lq2XpOcpv0ePxB57SPE30rBvsgw/view?usp=sharing maybe this will work. It it still does not work, maybe you can compile from source and see if there are any errors. Thank you for the interest in my game.

            8Observer88 Offline
            8Observer88 Offline
            8Observer8
            wrote on last edited by 8Observer8
            #25

            @johngod this build works without problems above. I didn't select the discrete video card manually to run. But when I move the ship with the AD keys from side to side, the animation of the movement is very choppy, like in a slideshow.

            johngodJ 1 Reply Last reply
            0
            • 8Observer88 8Observer8

              @johngod this build works without problems above. I didn't select the discrete video card manually to run. But when I move the ship with the AD keys from side to side, the animation of the movement is very choppy, like in a slideshow.

              johngodJ Offline
              johngodJ Offline
              johngod
              wrote on last edited by
              #26

              @8Observer8 I had problems whith choppy movement all over the place, because of using a Timer with a fixed valued has Crhis Kawa exaplained in https://forum.qt.io/post/278010 . But it got partially solved when changing Timer to FrameAnimation, however the AD keys are using a camera drift animation which is still buggy. Also using FrameAnimation breaks the AD keys drift animation, I still have to fix this bugs.
              If you click on the button "?" you will see some options where you can change back from FrameAnimation to Timer, and a lot more "chopiness" will appear.

              1 Reply Last reply
              1
              • 8Observer88 Offline
                8Observer88 Offline
                8Observer8
                wrote on last edited by 8Observer8
                #27

                I added the next comment to the bug report: https://bugreports.qt.io/browse/QTBUG-123862

                Try to run my example on macOS and Linux. Maybe it is a Windows issue. But requestAnimationFrame works perfectly smoothly on Windows: https://plnkr.co/edit/DebSXYMQ6TlgC7KT?preview It has a fixed 60 FPS, which means that the load on the processor is minimal.

                The worst result was with swapInterval=1, which I had at the beginning (I had not tried other values before). swapInterval with 0 and 10 is better, but not as good as requestAnimationFrame in JavaScript: https://plnkr.co/edit/B5t34XdK3MVi1WNb?preview (it is just a translation animation). I attached a source code "simple-translation-animation" (without rotation and scale animations). I attached EXE files for swapInterval = 0, swapInterval = 1, and swapInterval = 10:

                • swapInterval = 0 - simple-translation-animation-opengles2-qt6-cpp-win10x64-exe-swap-interval-0.zip
                • swapInterval = 1 - simple-translation-animation-opengles2-qt6-cpp-win10x64-exe-swap-interval-1.zip
                • swapInterval = 10 - simple-translation-animation-opengles2-qt6-cpp-win10x64-exe-swap-interval-10.zip

                4623e1c6-0872-494d-881f-3b9677f8c17c-image.png

                1 Reply Last reply
                1
                • johngodJ johngod referenced this topic on

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved