GodotSteamKit Tutorials - Avatars
By Gramps
This tutorial will cover the basics of using the Steam Avatar custom nodes from the GodotSteamKit.
Usage
Once you have the GodotSteamKit installed, there will be three new texture nodes: SteamAvatar, SteamAvatar3D and SteamAvatarRect which are the Sprite2D, Sprite3D, and TextureRect nodes, respectively.
You can set the user's Steam ID directly to the steam_id property or use its setter method, set_steam_id:
# Assigning the property directly
steam_avatar.steam_id = new_steam_id
# Alternatively setting the steam_id property by using the setter function
steam_avatar.set_steam_id(new_steam_id)
Once the Steam ID is set, the node will call getPlayerAvatar() with whatever you set the avatar_size property to; this will default to a medium avatar / 64 pixels.
Any time the player updates their avatar in Steam, this node should receive a persona_state_change callback and then request and update the visible avatar to match.
Properties
avatar_size
The size of the requested avatar. Small is 32 pixels, medium is 64 pixels, and large is 184 pixels. This property defaults to medium. These are also the Steam AvatarSizes enums.
custom_size
Sets a specific size for the Steam avatar which will override the avatar sizes. Make sure this is smaller than the avatar_size property you are using. For example, if custom_size is set to 50 pixels then select AVATAR_MEDIUM (or 2) as your avatar_size.
steam_id
The Steam ID associated with this avatar. Used to retrieve the current avatar and check the avatar and persona callbacks.
Functions
set_steam_id
This is the setter function for steam_id which will set the Steam ID to track and automatically requests the current avatar.
Troubleshooting
If no avatar is displayed at any point, check to see if your callbacks are enabled. You may also want to print the node's steam_id property to make sure it is what you are expecting:
print("Steam Avatar set as: %s" % steam_avatar.steam_id)