Adding Avatar Agents or NPCs

Avatar models can be brought in if they are in either the .fbx, .glTF or .cfg (cal3D) format

For more information on adding avatars, see this tutorial 

or see the Vizard Documentation on avatars

For intelligent avatar agents, see this page

Avatar agents or NPCs (non-player characters) are avatars in the scene that don't represent an actual user, but rather an agent in the scene that is controlled by code or AI and can act out scenes or interact with users. 

Here are the steps on how to add one to your experiment

Click "Inspector" or open Inspector and open your environment model

Click "File-Add" and in the "utils- resources- objects" folder choose the standInAvatar.osgb

Click on the "avatarTransform" node in the scene graph and then use the translate and rotate tools to move and rotate where you want your NPC in the scene. When you are finished make sure to choose File-Save

Open the avatar you are going to use in Inspector separately and preview any animations that you have available under the "Animations" tab. 

Important Notes:

The avatarPlacer module is specifically designed to work with GEODE nodes in the scene graph. Always provide the name of the GEODE node you wish to target. Using other types of nodes may lead to unexpected behavior or errors.

Instructions to place in code:

Add the following code to your script for single user. For multi-user add it to both the client and server scripts.

Note: this code can also be found in the "example_scripts" folder under "", where "state(1)" refers to the idle animation that you wish to have the NPC/agent start with and "avatar =vizfx.addAvatar('vcc_male.cfg')" would be swapped out with the name and path to your avatar model.  There are also example scripts for the multi-user version. 

#import necessary modulesimport vizimport vizfxfrom utils import sightlabfrom utils import avatarPlacer
#set GUI to 0 if not using SightLab GUIsightlab.is_GUI = 0
#Set environmentenv = vizfx.addChild('utils/resources/environment/ShowRoom_standin_avatar.osgb')sightlab.objects.append(env)
#Add avatar and give path to your avataravatar =vizfx.addAvatar('utils/resources/avatar/full_body/RocketBox_Male1.osgb') 
#Collect eye tracking data on avatarsightlab.gazeObjectsDict = {'avatar':avatar}
#run sightlab experimentimport viztaskdef sightLabExperiment(): yield viztask.waitKeyDown(' ') print('experiment start') #Place avatar, put name of environment model, name of avatar and name of standIn avatar, avatar, 'avatarStandin')  # Using the place function from avatarPlacer #set Avatar animation state avatar.state(1) yield viztask.waitKeyDown(' ') print('experiment end') viztask.schedule(sightlab.experiment)viztask.schedule(sightLabExperiment)

If you don't have a standin Avatar, the Avatar will be placed at the default position of 2 meters back and rotated 180 degrees to face the user. Can also override the position and rotation using this code:

avatar.setPosition(0, 0, 2)

avatar.setEuler(180, 0, 0)

You will also need to add this code to your sessionReplay script in order for the avatar to be seen in the replay. 

import viz

import vizfx

from utils import session_replay

if __name__ == '__main__':

session_replay_object = session_replay.AvatarReplay(session_replay.replayfileName[session_replay.trialNumber-1],session_replay.trackingfileName[session_replay.trialNumber-1])

from utils import avatarPlacer

env = session_replay_object.objects[0]

sceneAvatar = env.getChild('standInAvatar')


avatar =vizfx.addAvatar('utils/resources/avatar/full_body/RocketBox_Male1.osgb'), avatar, 'avatarStandin')  # Using the place function from avatarPlacer


For avatar resources see some of the following libraries. There are also more included avatars in your resources- avatar folder: 

Additionally, a few good resources for creating new animations using just a 2D camera are