Forums

OverviewV-Play 2 Support (Qt 5)Distance joint length › Reply To: Distance joint length

OverviewV-Play 2 Support (Qt 5)Distance joint length › Reply To: Distance joint length
#10142

Günther
V-Play Team

Hi totalzero!

I looked into the matter. Within the DistanceJoint implementation, a certain scaleRatio is applied to the length value whenever a new length is set. If you set the length to a new value, everything works fine. But when you read the length at a later point, you get the modified length that is used internally.

For the moment, you can fix this problem by manually calculating the “real” length when you need it:

// ...
  property var myJoint
  property  real scaleRatio

// ...

  // 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": 200
                                          })


      // myJoint.length holds the modified value, as we know that the "real" value is 200,
      // we can calculate the scaleRatio that is applied within the distance joint
      scaleRatio = 200 / myJoint.length 

      togetherTimer.start()
    }
  }

  Timer {
        id: togetherTimer
        // ...
        onTriggered: {
            console.debug("")
            var realJointLength = myJoint.length * scaleRatio
            console.debug("LENGTH: "+myJoint.length)
            console.debug("SCALE-RATIO: "+scaleRatio)
            console.debug("REAL LENGTH: "+realJointLength)
            console.debug("")
  //          if(myJoint.length > heavyBox.width/2 + lightBox.width/2){
              myJoint.length = realJointLength - 10
  //          }
        }
    }

 

This is just a workaround for now. I think we can fix this problem and include the correct version in the next V-Play update.
Thanks for reporting this issue!

Best,
GT

 

 

 

 

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