User

Steam Friends is a core component of the Steam platform that enhances the social experience of gaming by connecting players in real time. In this article, we’ll explore the Steam Friends interface provided by the Steamworks SDK, which offers a rich set of features for managing user profiles, friend lists, game invitations, and in-game communication. Whether you’re looking to integrate friends’ status updates or create custom matchmaking experiences, understanding Steam Friends is essential for creating a more connected and engaging game environment.

Examples

User Profile

Steam provides a lot of rich information about your friends, and this can be used in-game for many purposes, such as a visually rich display for your local user and or the other players they are playing with.

Code Free

You can use the User modular component to work with user data in your game. Modular components start empty and can be tailored to the specific need.

Empty User component
Empty User component
User component with Avatar, Hex (Input Field), Level, Name and Status as shown in the example image above

Local User

When true, the player (local user) data will be loaded; otherwise, you will need to set the user you want it to load, such as from a lobby member list, friend list, etc.

Fields

Using the Fields control, you can add fields that will be set based on the loaded user. That is, if you add an Avatar, then set the user from, say, your friends list, it will get that friend's avatar and update the image you reference.

Configuration

Using the configuration control, you can toggle on and off additional functionality such as Events and Invite options.

C#

Friend List

Tools for querying the list of friends are available and allow you to create detailed visual friend lists using your engine of choice's built-in UI tools.

Code Free

Use the Friend List component to get a list of the local user's (player's) friends and display those friends to a target transform.

Include Followed

A little-used feature, this will expand the search to include Clans the user is following. The Steam Clan aka Steam Group feature is not currently well supported by Valve but is included for completeness' sake.

Filter

Specify the sub-set of the user's friends you would like to have returned if any.

Content & Record Template

Content is simply the Transform you want the tool to spawn objects to. This would typically be a Layout Group control such as Unity's built in Vertical Layout Group.

Record Template

The Record Template is the object that will be spawned for each user found. This should contain a "User" component as demonstrated in the User Profile example.

C#

Invite to Game

You can invite a friend to play a game with you, Note this is inviting them to a connection string, not a lobby. It is possible to invite a friend to a lobby as well, We will explain that in the Lobby article.

Code Free

Not applicable.

C#

Invite the user to the game

The user will see the invite in their Friend chat and can accept the invite there. When they accept the invite, what happens next depends on whether or not they are currently playing this game.

If they are playing this game, then the Rich Presence Join Requested event will be raised. You can listen to this event via our Steamworks Event Triggers

Or you can listen in code

If the user was not already playing the game when they clicked the Accept button. Then, Steam will launch the game with the connection string on the command line. Valve doesn't document this well, but this code should get you going with reading the command line value.

Last updated