Reacting on joining and leaving users

This example creates a sphere above the head of each user who joins a collaboration session. A greeting message is displayed on the console for each new user.

vr/handleVRCollabUsers.py
 1# © 2024 Autodesk, Inc. All rights reserved.
 2
 3def userArrived(user):
 4    print((user.getUserName() + " has arrived"))
 5    # create s sphere above the head of the new user
 6    color = user.getUserColor()
 7    sphere = createSphere(2, 200, color.redF(), color.greenF(), color.blueF())
 8    setTransformNodeTranslation(sphere,0,700,0,False)
 9    addChilds(user.getHeadNode(),[sphere])
10    myName = vrSessionService.getUser().getUserName()
11    hisName = user.getUserName()
12    # send a greeting only to this user
13    user.sendPython("print('Hi welcome {0} from {1}')".format(hisName,myName))
14
15def userLeaves(user):
16    print((user.getUserName() + " has left"))
17
18vrSessionService.userArrives.connect(userArrived)
19vrSessionService.userLeaves.connect(userLeaves)