12-22-2016 12:33 PM
01-16-2017 10:50 AM
pjenness said:
Rave185 said:
@pjenness
Thanks for the code sample! Just having a bit of trouble, it doesn't recognize the word User and continues to error out. Any idea why that could be happening?
HIya
Do you have this at the start of your script file?
using Oculus.Platform.Models;
-P
01-16-2017 10:52 AM
metrocube said:
Rave185 said:
Still having trouble getting custom player avatars working though. The generic fallback avatar works, but no custom ones.
The Unity OvrAvatar is pre-wired to personalize avatars if you set the avatar's oculusUserID to a valid user ID. There's a trick though. Because the avatar gets created in the Start() function, you have to request and receive the user ID in an Awake() function. If you try to do it in Start(), it's too late.
Note: Even with Awake(), you can still get into a race condition because the call to get the user ID is asynchronous. You don't know how long it's gonna take.
The new docs will be live soon with some sample code that addresses all these gotchas in a straight-forward way.
The sample adds a new class that initializes Oculus Platform in an Awake() function, requests the ID of the logged in user, and then waits until the callback function updates the oculusUserID value of your avatar.
- Import the Oculus Platform SDK's unity package into your avatar project.
- Get a real App ID from API tab of your app in the Developer Dashboard. If you haven't made an app there, go to https://dashboard.oculus.com to set yourself up as a game dev and create your first app.
- Copy your App ID string into the "Rift app ID" setting in the Oculus Avatars and Oculus Platform plugins.
- Add this script to an empty game object:
PlatformManager.csusing UnityEngine;using Oculus.Avatar;using Oculus.Platform;using Oculus.Platform.Models;using System.Collections;public class PlatformManager : MonoBehaviour {void Awake () {Oculus.Platform.Core.Initialize();Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);Oculus.Platform.Request.RunCallbacks(); //avoids race condition with OvrAvatar.cs Start().}private void GetLoggedInUserCallback(Message<User> message) {if (!message.IsError) {OvrAvatar[] avatars = FindObjectsOfType(typeof(OvrAvatar)) as OvrAvatar[];foreach (OvrAvatar avatar in avatars) {avatar.oculusUserID = message.Data.ID;}}}}
01-16-2017 11:02 AM
01-16-2017 12:52 PM
01-16-2017 03:44 PM
01-16-2017 05:06 PM
01-17-2017 01:23 AM
01-17-2017 04:23 AM
01-17-2017 10:23 AM
01-19-2017 08:55 AM