Aw avatar set
Jump to navigation
Jump to search
Minimum requirements | ||
---|---|---|
Added in version 3.4 | ||
SDK | build 27 | |
World | build 44 | |
Browser | build 430 |
int aw_avatar_set (int session_id)
Description
Sets the attributes of a users avatar.
Callback
None (returns immediately)
Notes
This method triggers AW_EVENT_AVATAR_CHANGE for the user whose avatar is being set. During this event, AW_AVATAR_SESSION should be compared to the return value of aw_session to see if they match. If they do then the instance has been targeted by aw_avatar_set. Browsers will always change the attributes of their avatar; while bots are free to use the attributes as they see fit.
Note that setting the avatar of an SDK instance should be done using aw_state_change.
Arguments
- session_id
- Session number of the user.
Argument attributes
For SDK build 51, version 4.1; and later:
- AW_AVATAR_FLAGS
- Specifies the avatar attributes to be set.
- AW_AVATAR_X
- AW_AVATAR_Y
- AW_AVATAR_Z
- AW_AVATAR_YAW
- AW_AVATAR_PITCH
- AW_AVATAR_STATE
- AW_AVATAR_LOCK
Return values
- RC_SUCCESS
- RC_NOT_INITIALIZED
- RC_NO_INSTANCE
- RC_NO_CONNECTION
- Network connection to the world is down.
- RC_UNAUTHORIZED
- Only instances owned by a caretaker (i.e. aw_bool (AW_WORLD_CARETAKER_CAPABILITY) returns 1) and world server administration instances are allowed to use this method.
Returned attributes
None
Usage
Set the avatar type and gesture of a user.
void set_avatar (int session, int type, int gesture) { int rc; aw_int_set (AW_AVATAR_FLAGS, AW_AVATAR_SET_TYPE | AW_AVATAR_SET_GESTURE); aw_bool_set (AW_AVATAR_LOCK, 0); aw_int_set (AW_AVATAR_TYPE, type); aw_int_set (AW_AVATAR_GESTURE, gesture); rc = aw_avatar_set (session); if (rc != RC_SUCCESS) printf ("Unable to set avatar (reason %d)\n", rc); }
Determine if the avatar of a bot was set:
void handle_avatar_change (void) { if (aw_session () == aw_int (AW_AVATAR_SESSION)) { if (aw_int (AW_AVATAR_FLAGS) & AW_AVATAR_SET_TYPE) aw_int_set (AW_MY_TYPE, aw_int (AW_AVATAR_TYPE)); if (aw_int (AW_AVATAR_FLAGS) & AW_AVATAR_SET_GESTURE) aw_int_set (AW_MY_GESTURE, aw_int (AW_AVATAR_GESTURE)); if (aw_int (AW_AVATAR_FLAGS) & AW_AVATAR_SET_STATE) aw_int_set (AW_MY_STATE, aw_int (AW_AVATAR_STATE)); // ... aw_state_change (); } } aw_event_set (AW_EVENT_AVATAR_CHANGE, handle_avatar_change);