Add a child node to the node of a VR Controller¶
In this script a box is added as child to the node of the left and the right VR controller.
vr/attachToController.py¶
1# © 2024 Autodesk, Inc. All rights reserved.
2
3# Get left controller
4leftController = vrDeviceService.getVRDevice("left-controller")
5# Get right controller
6rightController = vrDeviceService.getVRDevice("right-controller")
7
8# Create a red box
9leftBox = createNode("Transform3D", "LeftBox", False)
10leftBox.addChild(createBox(100, 100, 100, 1, 1, 1, 1.0, 0.0, 0.0, 0.0))
11# Create a blue box
12rightBox = createNode("Transform3D", "RightBox", False)
13rightBox.addChild(createBox(100, 100, 100, 1, 1, 1, 0.0, 0.0, 1.0, 0.0))
14
15# Atttach the boxes to the controllers
16leftConstraint = vrConstraintService.createParentConstraint([leftController.getNode()], leftBox, False)
17rightConstraint = vrConstraintService.createParentConstraint([rightController.getNode()], rightBox, False)