avatar rotation sync
How can I make the avatar rotates the opposite way on the other players view, for example if I rotate left it should rotate right in the other players view and the other way around
RealtimeAvatarRealtimeAvatarRealtimeAvatarRealtimeAvatarRealtimeAvatarRealtimeAvatarRealtimeAvatarRealtimeComponentInvertedRotationAvatar.csRealtimeComponent<T>TInvertedRotationAvatarModel.csRealtimePropertyInvertedRotationAvatarRealtimeTransformRealtimeTransformusing Normal.Realtime;
using UnityEngine;
public class InvertedRotationAvatar : RealtimeComponent<InvertedRotationAvatarModel>
{
private RealtimeTransform _realtimeTransform;
private void Awake()
{
_realtimeTransform = GetComponent<RealtimeTransform>();
}
protected override void OnRealtimeModelReplaced(InvertedRotationAvatarModel previousModel, InvertedRotationAvatarModel currentModel)
{
if (currentModel != null)
{
// Subscribe to rotation changes
currentModel.rotationDidChange += RotationDidChange;
}
if (previousModel != null)
{
// Unsubscribe from the previous model
previousModel.rotationDidChange -= RotationDidChange;
}
}
private void RotationDidChange(InvertedRotationAvatarModel model, Quaternion value)
{
if (!_realtimeTransform.isOwnedLocallyInHierarchy)
{
// Invert the rotation for remote players
transform.rotation = Quaternion.Inverse(value);
}
}
private void Update()
{
if (_realtimeTransform.isOwnedLocallyInHierarchy)
{
// Update the model with the local rotation
model.rotation = transform.rotation;
}
}
}using Normal.Realtime;
using UnityEngine;
[RealtimeModel]
public partial class InvertedRotationAvatarModel
{
[RealtimeProperty(1, true)]
private Quaternion _rotation;
}