Using PhotonFusion with DoTween


Hello everyone,
I want to move an object using Photon Fusion, and I need to do this with DoTween. However, I cannot make the movement work. I can achieve the desired movement using transform.position, and I can also achieve it with DoTween. However, when I try to perform the DoTween operation on a NetworkedObject, no movement occurs. The NetworkObject also has the NetworkTransform component. Is this possible? I’ll leave my code block below. Thank you for taking the time to help!

[Networked] public bool isCardMoving { get; set; } = false;
[Networked] public NetworkObject TargetObject { get; set; }
private void Update()
{
    if (CardManager.instance.Counter.RemainingTime(Runner) <= 3f && isCardMoving)
    {
        isCardMoving = false;
        arrowDrawer.RemoveArrow();
        
        transform.DOMove(TargetObject.transform.position, 2.9f);
        
        Debug.Log(TargetObject.transform.position);
 
    }

If you check the DisableSharedModeInterpolation flag on the NetworkTransform, it should work. The reason it doesn’t work currently is because if you do not check this updating the position is only allowed in FixedUpdateNetwork.

First of all thank you for your feedback.
I followed your suggestion, but the issue remains the same. In fact, I had already tested it with the latest Update, and my code stayed that way. Initially, I was using it with FixedUpdateNetwork, and I started the game in host mode. Do you have any other suggestions for a solution?

public override void FixedUpdateNetwork()
{
    if (!Runner.IsServer) { return; }
    if (CardManager.instance.Counter.RemainingTime(Runner) <= 3f && isCardMoving)
    {
        isCardMoving = false;
        arrowDrawer.RemoveArrow();
        transform.DOMove(TargetObject.transform.position, 2.9f);
        Debug.Log(TargetObject.transform.position);

    }
    if (CardManager.instance.Counter.Expired(Runner) && isPlaying)
    {
        isPlaying = false;
        CardManager.instance.Counter = TickTimer.None;

        transform.DOLocalMove(StartPosition, 0.5f);

        RPC_PlayCard(TargetObject, gameObject.GetComponent<NetworkObject>());
    }
}

I was having the same issue, and the worst part is that there’s no information online about how to fix it—but I managed to figure it out.

It turns out the problem is related to the update ticks. I’m not entirely sure how it works or if the order of updates I’m about to mention is accurate, but it seems that the NetworkTransform updates its values before Update (which is the default update time for DoTween). As a result, it overwrites the new transform values changed by DoTween’s tweens.

To fix this, you need to change the update type of your tween and set it to LateUpdate to ensure that it runs after the NetworkTransform update and doesn’t get overwritten:

 transform.DOLocalMove(StartPosition, 0.5f).SetUpdate(UpdateType.Late);

Another option is to change the default settings in DoTween’s configuration to use LateUpdate as the update mode for all tweens. This way, you won’t need to write the .SetUpdate() instruction for each tween. You simply need to go to the Tools > Demigiant > DOTween Utility Panel window. Once the panel is open, go to the Preferences tab and change the Update Type option from Normal to Late:

I hope this helps!

3 Likes

Thanks setting .SetUpdate(UpdateType.Late); solved my issue and dotween worked as expected

its worked on me to, thank you ! :raised_hands: