homer987
homer987
NNormal
Created by homer987 on 3/28/2024 in #🤝ask-a-question
meta Avatar configuration
@Normcore Assistant in regards to avatar ownership, the script is not on the avatar prefab but rather attached to the Realtime + VR Player gameObject
23 replies
NNormal
Created by homer987 on 3/28/2024 in #🤝ask-a-question
meta Avatar configuration
@Normcore Assistant The situation is one where the avatar is rapidly switching between its own movements and the streamed movements from another player, leading to the observed flickering. Here is additional information about my set up: i have the local avatar in the scene and attached to the script I gave you. this avatar is mimicking the movement of the ovr camera rig. then i have the remote avatar which is also in the scene ( local and remote avatar for me are just a naming convention to differentiate between the two. but they are the same object in terms of settings, just being assigned to do different things from the script). i then drag these two avatars to the script. and then the flickering happens. is there anything in the script that points to what you said about situation where the avatar is rapidly switching between its own movements and the streamed movements from another player, leading to the observed flickering?
23 replies
NNormal
Created by homer987 on 3/28/2024 in #🤝ask-a-question
meta Avatar configuration
@Normcore Assistant here is the script
private byte[] byteArray = new byte[0];
public OvrAvatarEntity localEntity;
public OvrAvatarEntity remoteEntity;
public SampleAvatarEntity sampleAvatarEntity;

private bool remoteLoaded = false;
public bool isLocal = true;

private Realtime _realtime;
private bool connectedToRoom = false;
private bool avatarFound = false;

private RealtimeAvatarManager _manager;

private void Awake()
{
localEntity.OnUserAvatarLoadedEvent.AddListener(OnUserAvatarLoaded);
remoteEntity.OnUserAvatarLoadedEvent.AddListener(OnUserAvatarLoadedRemote);

_realtime = GetComponent<Realtime>();
_manager = GetComponent<RealtimeAvatarManager>();
_realtime.didConnectToRoom += DidConnectToRoom;
}
protected override void OnRealtimeModelReplaced(StreamDataModel previousModel, StreamDataModel currentModel)
{
if (previousModel != null)
{
previousModel.avatarAnimationDataDidChange -= OnAvatarAnimationDataChanged;
}
if (currentModel != null)
{
currentModel.avatarAnimationDataDidChange += OnAvatarAnimationDataChanged;
}
}

private void OnAvatarAnimationDataChanged(StreamDataModel model, byte[] data)
{
if (!avatarFound) return;
if (!remoteLoaded) return;
remoteEntity.ApplyStreamData(model.avatarAnimationData);
}

private void OnUserAvatarLoaded(OvrAvatarEntity avatarEntity)
{
StartCoroutine(StreamAvatarData(avatarEntity));
}

private void OnUserAvatarLoadedRemote(OvrAvatarEntity avatarEntity)
{
remoteLoaded = true;
}

private IEnumerator StreamAvatarData(OvrAvatarEntity avatarEntity)
{
while (true)
{
model.avatarAnimationData = localEntity.RecordStreamData(StreamLOD.Low);
yield return new WaitForSecondsRealtime(0.1f);
}
}
private byte[] byteArray = new byte[0];
public OvrAvatarEntity localEntity;
public OvrAvatarEntity remoteEntity;
public SampleAvatarEntity sampleAvatarEntity;

private bool remoteLoaded = false;
public bool isLocal = true;

private Realtime _realtime;
private bool connectedToRoom = false;
private bool avatarFound = false;

private RealtimeAvatarManager _manager;

private void Awake()
{
localEntity.OnUserAvatarLoadedEvent.AddListener(OnUserAvatarLoaded);
remoteEntity.OnUserAvatarLoadedEvent.AddListener(OnUserAvatarLoadedRemote);

_realtime = GetComponent<Realtime>();
_manager = GetComponent<RealtimeAvatarManager>();
_realtime.didConnectToRoom += DidConnectToRoom;
}
protected override void OnRealtimeModelReplaced(StreamDataModel previousModel, StreamDataModel currentModel)
{
if (previousModel != null)
{
previousModel.avatarAnimationDataDidChange -= OnAvatarAnimationDataChanged;
}
if (currentModel != null)
{
currentModel.avatarAnimationDataDidChange += OnAvatarAnimationDataChanged;
}
}

private void OnAvatarAnimationDataChanged(StreamDataModel model, byte[] data)
{
if (!avatarFound) return;
if (!remoteLoaded) return;
remoteEntity.ApplyStreamData(model.avatarAnimationData);
}

private void OnUserAvatarLoaded(OvrAvatarEntity avatarEntity)
{
StartCoroutine(StreamAvatarData(avatarEntity));
}

private void OnUserAvatarLoadedRemote(OvrAvatarEntity avatarEntity)
{
remoteLoaded = true;
}

private IEnumerator StreamAvatarData(OvrAvatarEntity avatarEntity)
{
while (true)
{
model.avatarAnimationData = localEntity.RecordStreamData(StreamLOD.Low);
yield return new WaitForSecondsRealtime(0.1f);
}
}
23 replies