Creating touch sensors
# This example shows how to create touch sensors and
# connect them to a variant set.
def createTouchSensor(node):
# Create the touch sensor first. This will create the needed
# attachment and register the touch sensor in VRED.
touchSensor = vrTouchSensor(node)
# To add a variant set, that will be called whenever the touch
# sensor is activated, we need to modify the attachement and
# add the variant set directly.
touchSensorAtt = node.getAttachment("TouchSensorAttachment")
touchSensorAttAccess = vrFieldAccess(touchSensorAtt)
# Note: this takes a list as parameter, so you can trigger multiple
# variant sets
touchSensorAttAccess.setMString("variantSets", ["toggleColor"])
return touchSensor
tsensor1 = createTouchSensor(findNode("Cone"))
tsensor2 = createTouchSensor(findNode("Box"))
# The update will force the touch sensors UI to refresh
vrController.updateTouchSensors()