Hi. I have dynamically created objects in my game that are connected by a distance joint and I want the length of the distance joint to change over time. As an example I’ve edited the Distance.qml file from box2d-examples to show what I want to achieve. However, when the distance joint is created the length property doesn’t set accurately. Do you know why this is happening? Thanks, Phil
import QtQuick 2.0
import Felgo 3.0
GameWindow {
property var myJoint
//...
// Timer that keeps creating heavy balls that crash down on the building
Timer {
//...
onTriggered: {
//...
myJoint = extraJoint.createObject(world,
{
"bodyA": ball1.body,
"bodyB": ball2.body,
"world": world,
"collideConnected": true,
"length": 400
})
togetherTimer.start()
}
}
Timer {
id: togetherTimer
repeat: true
running: false
interval: 1000
onTriggered: {
console.debug("")
console.debug(myJoint.length)
console.debug("")
// if(myJoint.length > heavyBox.width/2 + lightBox.width/2){
myJoint.length = myJoint.length - 10
// }
}
}
Scene {
//...
}
EntityManager {
//...
}
}