docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Sample: View avatars in Unity Cloud projects

    This sample shows you how to control your avatar and view the avatars of other participants in a project.

    For a better user experience, you can join a room from multiple clients. To join a room from multiple clients, see the following steps:

    • Run the sample on two machines and join the same room.
    • Build the sample scene and run the build at the same time as the sample in the Unity Editor.
    • Run the sample in two instances of the Unity Editor at the same time.

    Before you start

    To use the sample, you require the following:

    • Installed Presence package
    • Installed Identity package
    • A valid Unity ID
    • A Unity Cloud Project associated with your Unity ID
    • Tried out the Monitor and Join Rooms to learn how to join rooms.
    Note

    While the Presence service doesn't depend on the Assets and Identity services directly, they are used in the sample to control the authentication process.

    Install the sample

    To install the sample, see the following steps:

    1. Inside your Unity Editor Project window, go to Package Manager > Unity Cloud Presence.
    2. Expand the Samples section.
    3. On the right of the Avatars sample, select Import.
      Screenshot of the samples import section of the package manager window

    After the import process is complete, you can view your imported assets under the Assets/Samples/Unity Cloud Presence folder.
    Screenshot of the imported sample

    Launch the sample

    To launch the sample, see the following steps:

    1. Go to Assets/Samples/Unity Cloud Presence/<package-version>/Avatars/Scenes/AvatarSample.unity and run the scene. If this is your first time launching the sample, make sure to sign in with your Unity ID account and that you have a Unity Cloud project created.
    2. Select and join a room as demonstrated in the Monitor and Join Rooms sample.

    View the avatars of other participants

    At least two participants must have joined the room for you to view the avatars in a project. The avatars populate when a second participant joins the room.

    To view and move your avatar inside a Unity scene, see the following steps:

    1. Join a room. Your avatar appears inside the project the room is attached to.
    2. Use the controls listed on the screen to move your avatar. As other participants control their avatars, their avatars move on your screen.
      Screenshot of avatars

    Main components

    This section describes the scripts that make up the main components of this sample.

    Avatar manager script

    The AvatarManager script interacts with the INetcodeService class to notify you when a new INetcodeParticipant is added or removed. Each INetcodeParticipant represents a participant for which a new avatar is instantiated or destroyed.

    To open the AvatarManager sample script, go to your Assets/Samples/Unity Cloud Presence/<package-version>/Avatars/Scripts/AvatarManager.cs file.

    Avatar script

    The Avatar script shows you how to do the following:

    • Perform simple movement actions for an avatar
    • Send or receive transform information for the avatar via the INetcodeParticipant class

    To open the Avatar sample script, go to your Assets/Samples/Unity Cloud Presence/<package-version>/Avatars/Scripts/Avatar.cs file.

    Troubleshooting

    Refer to the troubleshooting section for help with sample issues.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)