Variable serialization of the sleeping object

I’m trying to serialize variables of pickupable object but it won’t while it is in “Should Sleep” mode.
If the object is not held, it enters sleep mode.
Is there any way to serialize when it is sleeping or make it wake up temporary?

‘Rigidbody.WakeUp()’ doesn’t working and also ‘RequestSerialization’ method is not working too while it is sleeping.

I solved this problem by myself.

How did you solve your problem? It may be helpful to future users who face the same issue.

Set the Synchronization Method as ‘Manual’ and updating transform manually.
And use the ‘RequestSerialization’ method manually when needed to serialize variables of the script.

This method requires the removal of the ‘VRC Object Sync’.

This is what I did.

image

public class SYNCTEST : UdonSharpBehaviour
{
    public VRC_Pickup m_pickup;
    [UdonSynced] Vector3 m_position;
    [UdonSynced] Vector3 m_rotation;
    Vector3 m_positionVelo;
    Vector3 m_rotationVelo;
    float m_transSpeed = 0.05f;

    private void Update()
    {
        UpdateTransform();
    }

    public override void OnPlayerJoined(VRCPlayerApi player)
    {
        // Sync transform for late joiner.
        if (Networking.IsOwner(Networking.LocalPlayer, gameObject)) RequestSerialization();
    }

    void UpdateTransform()
    {
        // Owner
        if (Networking.IsOwner(Networking.LocalPlayer, gameObject))
        {
            if (m_position != transform.position || m_rotation != transform.eulerAngles)
            {
                m_position = transform.position;
                m_rotation = transform.eulerAngles;
                RequestSerialization();
            }
        }
        // Remote
        else
        {
            // Drop if object holding has been stole by someone else
            if (m_pickup.IsHeld) m_pickup.Drop();
            // Keep updates transform smoothly
            transform.position = Vector3.SmoothDamp(transform.position, m_position, ref m_positionVelo, m_transSpeed);
            transform.eulerAngles = new Vector3(
                Mathf.SmoothDampAngle(transform.eulerAngles.x, m_rotation.x, ref m_rotationVelo.x, m_transSpeed),
                Mathf.SmoothDampAngle(transform.eulerAngles.y, m_rotation.y, ref m_rotationVelo.y, m_transSpeed),
                Mathf.SmoothDampAngle(transform.eulerAngles.z, m_rotation.z, ref m_rotationVelo.z, m_transSpeed)
            );
        }
    }
}