Avatar Setup and Functionality¶
- Avatar Setup and Functionality
- Avatar Creation
- Avatar Visibility
- Avatar Data
- Avatar Gestures
- Notifications
- System Messages
- Comments
This is an overview of how avatars are created in the scene, what information is stored about the avatars in the scene, common scripts such as system message and notification handling contained within the avatar functionality IMML, etc.
Avatar Creation¶
When the avatar creation functionality loads, and it is confirmed that a connection with the server has been established, a custom message is sent to the server containing the users desired avatar name. The server responds with the avatar name, current server time and spawn point position and rotation.
The avatar is written into the scene with visibility set to false, and along with a range of network filters and triggers, 3 network enabled text elements are also included specifying the users login time, alias and VOIP channel ID.
When the "OnAvatar-Loaded" script executes, the obj is checked to determine if it is your avatar or another users.
If the avatar belongs to you:
- The model visibility is set to true.
- The avatar plugin is setup.
- The avatar camera chase properties are setup.
- The smart camera functionality is enabled, if available.
- The "Avatar-SetBlink" timeline is enabled, which will execute the script to setup the blinking animation on the avatar.
If the avatar belongs to another user:
- The users alias is retrieved from the nested text element, and stored in an object variable.
- The object is added to the 'avatar-visiblequeue' list, along with the current UTC time. The "Avatar-UpdateVisibility" timeline is then enabled.
- The users audio orb colour is set, if it exists, depending on the users channel ID.
- The "OnAvatar-GetProfileData" script is executed on a new thread to get the users profile information.
Avatar Visibility¶
As avatars are added to the scene invisible, and a network filter is applied to not update the elements visibility over the network, it is the responsibility of each client to set all other avatars "Visible" property to true. This is done to create a short delay from the time the avatar loads to the time the avatar is visible, to avoid seeing the avatar in T-pose for a short time as the animation is first applied.
As mentioned above, when other avatars load they are added to the 'avatar-visiblequeue' list, along with the current UTC time. The "OnAvatar-UpdateVisibility" script is executed every 2 seconds to check for any elements within this list that were added more than 1.5 seconds ago. If an avatar is found to meet this criteria, its visibility is set to true and it is removed from the list.
Avatar Data¶
To retrieve your own avatar model, you can get the scene variable: 'avatar-model'.
myAvatar = scene:get('avatar-model')
To retrieve another users alias from their avatar model, you can get the object variable: 'avatar-alias'.
userAlias = avatarObj:get('avatar-alias')
To retrieve all avatars in the scene, including your own, along with the users alias and vastsocial profile data (If available) the scene variable: 'avatar-data' can be used.
avatarData = scene:get('avatar-data')
This returns a list, which contains:
- Avatar Model
- Users Alias
- VastSocial Profile Information
When checking for the profile information, you should first check if this value is nil. If you are logged in as a guest, or the other user is a guest, or the user is not found on vastsocial, this information will not be retrieved.
The profile information is stored in a list, which contains:
- User Alias
- Profile Image URI
- Description
- Brief Description
- Location
- Interests
- Skills
- Contact Email
- Phone
- Mobile
- Website
- Relationship
Avatar Gestures¶
Avatar gestures can be performed by executing one of the available gesture scripts. At the time of writing, the available gesture scripts are:
- OnAvatar-Gesture-Yes
- OnAvatar-Gesture-No
- OnAvatar-Gesture-OK
- OnAvatar-Gesture-RaiseArm
- OnAvatar-Gesture-Point
- OnAvatar-Gesture-Wave
- OnAvatar-Gesture-Clap
- OnAvatar-Gesture-ScratchHead
- OnAvatar-Gesture-DontKnow
- OnAvatar-Gesture-Disappointed
Executing one of these scripts will perform the corresponding gesture. An object can also be passed into the script using :execute(obj, nil) which will cause your avatar to face the object passed in and perform the gesture, also notifying other users that the gesture was performed at another avatar. Currently, the object passed in must be another avatar.
Notifications¶
Notifications (The pop-ups on the bottom right) are used quite regularly. Because of the, the setting of notifications was made to be as simple as possible. The script "OnNotification-Set" is executed, with a list passed in containing the required information for the notification. An example script:
if(scene:containsname('OnNotification-Set')) then
notificationdata = list()
notificationdata:add('This is the Notification Message!')
notificationdata:add('success')
scene:getelement('OnNotification-Set'):execute(nil, notificationdata)
end
The first line ensures that the script is available in the scene before continuing. The notificationdata list is then created. This contains the message to be displayed, along with the message type. The message type determines the colour coding of the notification. Available options are:
- avatarconnect -- For use in displaying when another user connects.
- avatardisconnect -- For use in displaying when another user disconnects.
- success -- A generic type, displays as green.
- fail -- A generic type, displays as red.
- publicchat -- For displaying public chat messages.
- privatechat -- For displaying private chat messages.
If the notification message extends beyond what can be displayed, the string is trimmed.
System Messages¶
System messages are sent out to one or more other connected clients. When received, the message is assembled based on the provided information and written to the chat window as a system message.
A system message can be sent by executing the script "OnSystemMessage-Send", with a list passed in containing the required information for the message. An example script:
if(scene:containsname('OnSystemMessage-Send')) then
messagedata = list()
messagedata:add('gesture')
messagedata:add(nil)
messagedata:add(obj.network.owner)
messagedata:add(obj:get('avatar-alias'))
messagedata:add(alias)
messagedata:add('waves')
scene:getelement('OnSystemMessage-Send'):execute(nil, messagedata)
end
In the above script, we first determine whether the script is available in the scene. We then prepare the message data to tell other users we have waved at another user. The message data will always include:
- The message type. ('gesture' in the above example)
- The client id to send the message to. (nil in the above example, making the message a broadcast message)
Depending on the message type, additional information can then be included.
Gestures
For message types of 'gesture' the information is:
- Target ID - The network ID of the user whom the gesture is directed to. Can be defined as 'nil' (string) if no target exists.
- Target Alias - The alias of the user whom the gesture is directed to. Can be defined as 'nil' (string) if no target exists.
- Source Alias - The alias of the user performing the gesture.
- Gesture - The gesture being performed.
When the message is received by other client(s) and no target is defined, the message displays as:
Source Alias Gesture.
For example:
"Kermit waves."
When the message is received by other client(s) and a target is defined, the message displays as:
Source Alias Gesture at Target Alias.
For example:
"Kermit waves at Swedish Chef."
If the gesture is directed at you, the message displays as:
Source Alias Gesture at you.
For Example:
"Kermit waves at you."
Teleport
For message types of 'teleport' the information is:
- Source Alias - The alias of the user teleporting.
- Location - The location the user is teleporting to.
When the message is received by other client(s), the message displays as:
Source Alias has teleported to Location.
For example:
"Kermit has teleported to The Haunted Castle."