Kinetix Documentation
Website
  • 🖐️Welcome
  • 🕺About Kinetix
  • 🖌️User-Generated Emote
    • 🤖Video-to-animation AI
    • 🤸Kinetix Emote Standards
    • 🦴Retargeting
    • 🏂Kinanim (Emote streaming)
    • 🖊️Try the User-Generated Emote feature
  • INTEGRATION
    • 🤷SDK or API: what to choose
    • 🤩Kinetix SDK
      • ⚙️SDK - Core Package
      • 🧩SDK - Sample scene
      • 🧑‍💻Tested & approved Game Engines for the SDK
      • 💻SDK Integration in Unity
        • ⬇️Set-up Unity & Import the SDK
          • 🔑Get your Game authentification API Key
          • ⚙️Setup your Unity environment
          • 🔧Install the Kinetix SDK in Unity
          • ⌨️SDK Initialization - Unity
        • ⚡Quickstart - Unity SDK
        • 🦋SDK Core Modules activation - Unity
          • 🔐Account Management in Unity
          • 💃Animation System - Unity
            • 🎢Unity's Animator System
            • 🎨Custom Animation System
            • 🌳Root Motion
              • RootMotion + NavMeshAgent
            • 🎞️Frame Controller
            • 💪IK Controller
            • 🫥Avatar Mask
          • 📶Network - Unity SDK
            • Photon PUN
            • Photon Fusion
        • 🕺User-Generated Emote integration (Unity)
          • Embedding the PWA in your Unity application
          • Validation / Retake
        • 🚧How to update Kinetix SDK in Unity?
        • 📕SDK API Reference - Unity
          • KinetixCore
          • KinetixCore.Account
          • KinetixCore.Animation
          • KinetixCore.Metadata
          • KinetixCore.Network
          • KinetixCore.UGC
        • 📂Unity SDK Changelog
      • 🕹️SDK Integration in Unreal Engine
        • ⬇️Set-up Unreal Engine & Download the SDK
          • 🔑Get your Game authentification API Key
          • ⚙️Set up your Unreal Engine environment
          • 🔧Install the Kinetix SDK in Unreal
          • ⌨️UE SDK Core Package Initialization
        • ⚡Quick Start
        • 🦋SDK Core Modules activation - Unreal
          • 🔐Account Management - UE
          • 💃Animation System - UE
            • Local player system in Unreal Engine
            • Avatar system in Unreal Engine
            • Without uploading an avatar (deprecated)
              • Animation in a Third Person Template
              • Animation in an existing project
          • 📶Network - UE SDK
        • 🕺User-Generated Emote integration (UE)
        • 📕SDK API Reference - UE
          • KinetixCore
          • KinetixCore.Account
          • KinetixCore.Animation
          • KinetixCore.Metadata
          • KinetixCore.Network
        • ⬆️Updating from 0.3 to 0.4
        • 📂UE SDK Changelog
    • 😍Kinetix API
      • 🔑Get your Authentification API key
      • 🔌API routes
      • 🪝API Webhooks
      • 🏓Possible Return Codes
  • Management
    • 🚪Developer Portal
      • 👽Avatar Upload
      • 👮UGC Moderation
    • 🖌️UGE: Guides & Best Practices
      • 📐User-Generated Emote specifications
      • 👌Video recording best practices
      • 👻User-Generate Emote Use Cases
  • SUPPORT
    • 📬Bugs reports & features requests
    • ❓FAQ
      • FAQ: General questions
      • FAQ: Unity SDK
      • FAQ: Unreal Engine SDK
    • 🤕Troubleshooting
    • 📚Glossary of terms
Powered by GitBook
On this page
  • 1. Reminder: Initialize the SDK and register a callback
  • 2. Register your local player
  • 3. Link your game's account system with Kinetix SDK
  • 4. Get ready to use User-Generated Emotes
  • 5. (After processing) Get the emote of your player
  • 6. Play the emote
  • You've done it!

Was this helpful?

Export as PDF
  1. INTEGRATION
  2. Kinetix SDK
  3. SDK Integration in Unity

Quickstart - Unity SDK

Get started with the Unity SDK in under 10 minutes.

If you followed the Set-up Unity & Import the SDK section, your script should look something like this:

[SerializeField] private Animator myAnimator;
[SerializeField] private string myConnectedUserID;

private void Awake() 
{
	KinetixCore.OnInitialized           += OnInitialize;
	KinetixCore.Initialize(new KinetixCoreConfiguration()
	{
		GameAPIKey = "yourGameAPIKey",
		PlayAutomaticallyAnimationOnAnimators = true,
		EnableAnalytics = true
	});
}

// This callback is used for the actions made after the SDK is initialized
// Such as initializing the UI and Registering our LocalPlayer's animator
private void OnInitialize()
{
	// Register local player to receive animation
	// See "Animation System" documentation
	KinetixCore.Animation.RegisterLocalPlayerAnimator(myAnimator);

	// Now, we connect the current user's account to get his emotes
	// The userID is chosen by you, and must be unique to each user
	// See "Account Management" documentation
	KinetixCore.Account.ConnectAccount(myConnectedUserID, () => {
		Debug.Log("Account connected successfully");
	}, () => {
		Debug.LogError("There was a problem during account connection. Is the GameAPIKey correct?");
	});
}

Next, we'll finalize it to provide you with a complete template for integrating UGE into your game:

[SerializeField] private Animator myAnimator;
[SerializeField] private string myConnectedUserID;

private void Awake() 
{
	KinetixCore.OnInitialized           += OnInitialize;
	KinetixCore.Initialize(new KinetixCoreConfiguration()
	{
		GameAPIKey = "yourGameAPIKey",
		PlayAutomaticallyAnimationOnAnimators = true,
		EnableAnalytics = true
	});
}

// This callback is used for the actions made after the SDK is initialized
// Such as initializing the UI and Registering our LocalPlayer's animator
private void OnInitialize()
{
	// Register local player to receive animation
	// See "Animation System" documentation
	KinetixCore.Animation.RegisterLocalPlayerAnimator(myAnimator);

	// Now, we connect the current user's account to get his emotes
	// The userID is chosen by you, and must be unique to each user
	// See "Account Management" documentation
	KinetixCore.Account.ConnectAccount(myConnectedUserID, () => {
		Debug.Log("Account connected successfully");

		// You can subscribe to an event to refresh the link when it is expired 
    		// (after 5 minutes or when an UGE has been submitted with the current token)
   		KinetixCore.UGC.OnUGCTokenExpired += DisplayUGELink;

    		DisplayUGELink();
	}, () => {
		Debug.LogError("There was a problem during account connection. Is the GameAPIKey correct?");
	});
	
	
}

IEnumerator FetchEmotesAtInterval()
{
	while (enabled)
	{
		// Fetch emotes every 5 minutes
		yield return new WaitForSeconds(300);
		
		GetPlayerEmotes();
	}
}

public void DisplayUGELink()
{
    	// Example on how to get the link
    	KinetixCore.UGC.GetUgcUrl((_Url) => {
        	// Enable your UI (a button somewhere in you GUI?) here and 
		// assign it the url to the web app
    	});
}

// Maybe use a coroutine to fetch the anim every 5 minutes ?
public void GetPlayerEmotes()
{
	// We get the animation 
    	KinetixCore.MetadataGetUserAnimationMetadatas(OnPlayerEmoteFetched);
}

public void OnPlayerEmoteFetched(AnimationMetadata[] _Emotes)
{
	// Let's play the last emote we fetched
    	PlayEmote(_Emotes[_Emotes.Length - 1].Ids.UUID);
}

public void PlayEmote(string _MyEmoteID)
{
    	// Finally we can play the animation on our local player
	KinetixCore.Animation.PlayAnimationOnLocalPlayer(_MyEmoteID);
}

Let's review the different steps of the code together!

1. Reminder: Initialize the SDK and register a callback

Before Initializing the SDK (which is an asynchronous process), you can register a callback to call subsequent functions of the SDK:

KinetixCore.OnInitialized += OnInitialize;

Then, you can initialize the SDK with the configuration you want:

KinetixCore.Initialize(new KinetixCoreConfiguration()
{
	GameAPIKey = "yourGameAPIKey",
	PlayAutomaticallyAnimationOnAnimators = true,
	EnableAnalytics = true
});

More info: SDK Initialization - Unity

2. Register your local player

Your character has to be an humanoid

To play emotes, you can use an already configured character from your game which has an animator for exemple (custom animation systems are supported, please visit Animation System - Unityfor more info) You can call the RegisterLocalPlayerAnimator method to easily register a character

// Register local player to receive animation
// See "Animation System" documentation
// myAvatarID is optionnal and allows you to play an emote specifically retargeted for your uploaded avatar in the Developer Portal
KinetixCore.Animation.RegisterLocalPlayerAnimator(myAnimator, myAvatarID);

If you uploaded an avatar in our Developer Portal, you can also pass the avatarID matching the player character you registered to benefit from the Contact-Aware Retargeting.

More info: Animation System - Unity

3. Link your game's account system with Kinetix SDK

We will focus on this part of the code:

// Now, we connect the current user's account to get his emotes
// The userID is chosen by you, and must be unique to each user
// See "Account Management" documentation
KinetixCore.Account.ConnectAccount(string myConnectedUserID, () => {
	Debug.Log("Account connected successfully");
}, () => {
	Debug.LogError("There was a problem during account connection. Is the GameAPIKey correct?");
});

We use the ConnectAccount method, establishing a link between the user account on your end and within Kinetix's system.

The userID you give to Kinetix must be reused each time you want to connect this specific user, and it must remain exclusive to them.

While it can be a hash or any string, we highly recommend anonymizing user data and refraining from incorporating any personal information.

More info: Account Management in Unity

4. Get ready to use User-Generated Emotes

Let's check the following code (inside the success callback of ConnectAccount)

// You can subscribe to an event to refresh the link when it is expired 
// (after 5 minutes or when an UGE has been submitted with the current token)
KinetixCore.UGC.OnUGCTokenExpired += DisplayUGELink;

DisplayUGELink();

[...]

void DisplayUGELink()
{
    // Example on how to get the link
    KinetixCore.UGC.GetUgcUrl((_Url) {
        // Enable your UI (a button somewhere in you GUI?) here and 
	// assign it the url to the web app
    });
}

As you can see, we provide a way to know when a link / token to the Web Application is invalid (either because of the security token expiration or after usage).

More info: User-Generated Emote integration (Unity)

5. (After processing) Get the emote of your player

To get your player's emotes, you can call GetUserAnimationMetadatas, which will return an array of AnimationMetadata, containing all the info you will ever need (name, thumbnail, file links, etc...)

// Maybe use a coroutine to fetch the anim every 5 minutes ?
public void GetPlayerEmotes()
{
	// We get the animation 
    	KinetixCore.MetadataGetUserAnimationMetadatas(OnPlayerEmoteFetched);
}

public void OnPlayerEmoteFetched(AnimationMetadata[] _Emotes)
{
	// Let's play the last emote we fetched
    	PlayEmote(_Emotes[_Emotes.Length - 1].Ids.UUID);
}

As you can see you can get the Id of an emote by accessing the Ids.UUID property of an AnimationMetadata

More info: Account Management in Unity

6. Play the emote

Once we have the id of the emote we want to play (and the local player has been registered), we can just call:

public void PlayEmote(string _MyEmoteID)
{
    	// Finally we can play the animation on our local player
	KinetixCore.Animation.PlayAnimationOnLocalPlayer(_MyEmoteID)
}

More info: Unity's Animator System

You've done it!

You should be ready to use the SDK now! We encourage you to visit SDK Core Modules activation - Unity to expand your knowledge of the SDK or our SDK API Reference - Unityto check what methods are available.

PreviousSDK Initialization - UnityNextSDK Core Modules activation - Unity

Last updated 1 year ago

Was this helpful?

You can then call a method to get the link to the Web Application, and attach it to a script to open the web browser (for example with )

🤩
💻
⚡
Application.OpenURL