Hello everyone,
when rotating an entity which includes a particle emitter, the movement of the emitted particles is influenced by the rotation of the entity. The effect becomes more obvious for fast rotation velocities. Here is some code which showcases the behaviour:
main.qml:
import Felgo 3.0
import QtQuick 2.0
GameWindow {
id: gameWindow
activeScene: scene
width: 960
height: 640
EntityManager {
id: entityManager
entityContainer: scene
}
Scene {
id: scene
width: 480
height: 320
Item{
BoxCollider {
id: fix
x: scene.width / 2
y: scene.height / 2
bodyType: Body.Static
}
ParticleEmitter {
x: scene.width/2
y: scene.height/2
jointBody: fix.body
}
PhysicsWorld {
id: world
updatesPerSecondForPhysics: 60
gravity.y: 0.0
velocityIterations: 5
positionIterations: 5
running: true
}
}
}// scene
}
ParticleEmitter.qml:
import QtQuick 2.0
import Felgo 3.0
EntityBase {
id: root
width: 40
height: 10
//transformOrigin: Item.TopLeft
property variant jointBody: null
property alias body: collider.body
BoxCollider {
id: collider
width: root.width
height: root.height
x: -root.width / 2
y: -root.height / 2
density: 0.05
torque: {
0.01;
}
Rectangle {
id: rect
anchors.fill: parent
color: "red"
}
}
RevoluteJoint {
id: joint
bodyA: body
bodyB: jointBody
localAnchorA: Qt.point(-20, 0)
world: physicsWorld
}
Particles{
id: particles
x: 20
}
}
Particles.qml
import QtQuick 2.0
import Felgo 3.0
ParticleVPlay {
id: particle
fileName: "FireParticle.json"
startParticleSize: 10
startParticleSizeVariance: 0
finishParticleSize: 10
finishParticleSizeVariance: 0
particleLifespan: 3
positionType: ParticleVPlayBase.Free
// start when finished loading
autoStart: true
}
For the particles “FireParticle.json” and “particleFire.png” are used which are included in the ParticleEditor demo.
Any hint is highly appreciated!
Cheers,
Thomas