Forums

OverviewV-Play 2 Support (Qt 5) › Issues with ParticleVPlay slowing game down

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13643

    Kool

    Hi guys,

    I have in total around 300 entities in my scene. All of these entities need to have a ParticleVPlay, because each one can die somewhere in the scene and needs to ‘explode’ at that point.

    I’ve noticed that having 100+ ParticleVPlay has a major effect on FPS. The CPU and RAM usage shoots right up and I’m unsure as to why. I’ve reproduced this with the following example (you may need to substitute the json with your own):

    import VPlay 2.0
    import QtQuick 2.0
    
    GameWindow {
        id: gameWindow
    
        activeScene: scene
    
        screenWidth: 960
        screenHeight: 640
    
        EntityManager {
            id: entityManager
            entityContainer: scene
        }
    
        Scene {
            id: scene
    
            // the "logical size" - the scene content is auto-scaled to match the GameWindow size
            width: 480
            height: 320
    
            Repeater {
                model: 300
    
                ParticleVPlay {
                    id: particles
                    fileName: "explosion_blue.json"
                    autoStart: false
                    running: false
                }
            }
    
            PhysicsWorld {
                debugDrawVisible: true
            }
    
            Rectangle {
                color: "black"
                anchors.fill: parent
            }
    
            Rectangle {
                width: 100
                height: 25
                color: "white"
                anchors {top: parent.top; right: parent.right}
    
                Text {
                    text: "Move"
                    anchors.centerIn: parent
                }
    
                MouseArea {
                    anchors.fill: parent
                    onClicked: scene.move()
                }
            }
    
            function move() {
                player.y = 0;
                player.move()
            }
    
            EntityBase {
                id: player
                width: 25
                height: 25
                x: scene.width/2 - player.width
                y: 0
    
                Rectangle {
                    anchors.fill: parent
                    color: "red"
                }
    
                BoxCollider {
                    id: collider
                    bodyType: Body.Dynamic
                }
    
                MovementAnimation {
                    id: animation
                    target: parent
                    property: "y"
                    velocity: 100
                    maxPropertyValue: scene.height - player.height
                    onLimitReached: y = 0
                }
    
                function move() {
                    animation.start()
                }
            }
        }
    }
    

    Press the top right button to start moving the entity. Even though the particle effects aren’t being started, the FPS has dropped dramatically. Whilst it’s running, notice the high CPU and RAM usage.

    If you change the repeater model value to 10, it’s usable again.

    Any suggestions to achieve what I need?

    Thanks!

    #13645

    Günther
    V-Play Team

    Hi Kool!

    The ParticleVPlay type is based on the Qt Particle System and combines types like ParticleSystem, Particle and Emitter. This implementation is easy to use but might not be the best in performance if a big amount of particles is used. For example, each ParticleVPlay instance defines its own ParticleSystem which means 300 independent systems with particle emitters in your case.

    To achieve a better performance with many particles, you can try directly using these standard QML Particle types for your particle implementation. You could then use a single ParticleSystem that holds multiple particle emitters for your effects to get the best performance possible with the Qt types.

     

    Also, as I guess not all the Particles will be triggered at the same time, you could try to reduce the amount of active ParticleVPlay items. For example by creating and removing the ParticleVPlay items dynamically when they are needed. Another idea would be to hold a smaller pool of ParticleVPlay items that you position and start whenever an effect should be shown (so your entities share and use a fixed bool of particle items).
    Best,
    Günther

     

     

    #13646

    Alex
    V-Play Team
    #13660

    Kool

    Thanks for the advice.

    I’ve opted to create 10 particle effects and move their positions around the screen as required.

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support