Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The output is formatted ("%.2f" % averageVelocity) and clips the result to two digits, e.g. 3.67 instead of 3.671472813

Code Block
languagepy
activeObjects  = scene.getGlobalVariableValue("activeObjects")
numOfObjects   = len(activeObjects)
objectVelocity = 0.0
 
for entry in activeObjects:
	objectVelocity += entry.getVelocity().module()
 
averageVelocity = objectVelocity / numOfObjects
 
scene.message("The average velocity is "+str("%.2f" % averageVelocity)+" m/s")