Dash Mechanism is very glitchy in unity photon fusion multiplayer

I am working on a dash mechanism for 2D multiplayer game in unity with photon fusion. My requirement is that when the player presses LShift, they will move at a lower speed and a UI to charge the slider will be shown. The player can hold LMb to their desired charge and release to dash. Later which I want my player to move with default speed. Also the player by pressing RMb, can cancel the charge on or before charging so that he/she doesn’t dash and move with default speed.

Everything works completely fine expect for the dashing part as it gives a jerky movement especially on the client. The below is the code I have for the same.

using UnityEngine;
using Fusion;

public class Player : NetworkBehaviour
{
    public Rigidbody2D PlayerRigidbody;

    private float _dashSpeed = DataUtils.DashSpeed; // Speed of the dash
    private float _lastDashTime = -Mathf.Infinity;
    private Vector2 _movement;

    public float minDuration; // Minimum ability duration
    public float maxDuration = DataUtils.MaxDashDuration; // Maximum ability duration

    public CharacterCanvasBase Canvas;

    public override void FixedUpdateNetwork()
    {
        // player direction input to dash
        _movement = DirectionInput;

        // below is psuedo code
        if (LShiftPressed)
        {
            StartCoroutine(Dash());
        }
    }

    private IEnumerator Dash()
    {
        _lastDashTime = Time.time;

        Vector2 startDashPosition = PlayerRigidbody.position;
        Vector2 dashDirection = _movement.normalized;

        // Check if the player is moving. If not, dash downward
        if (dashDirection == Vector2.zero)
        {
            dashDirection = Vector2.down; // Or any default direction you prefer
        }

        // Get charge level to determine dash speed and possibly duration
        float chargeLevel = Canvas.GetComponent<HexCanvas>().ChargeController.GetChargeProgress();
        float adjustedDuration = minDuration + (maxDuration - minDuration) * Mathf.Pow(chargeLevel, 2);
        float dashEndTime = Time.time + adjustedDuration;

        while (Time.time < dashEndTime)
        {
            float dashProgress = (Time.time - _lastDashTime) / adjustedDuration;
            RPC_DashMove(startDashPosition, dashDirection, dashProgress, _dashSpeed * adjustedDuration);
            yield return null;
        }
    }

    [Rpc(RpcSources.All, RpcTargets.All)]
    public void RPC_DashMove(Vector2 startDashPosition, Vector2 dashDirection, float dashProgress, float dashSpeed)
    {
        PlayerRigidbody.MovePosition(Vector2.Lerp(startDashPosition, startDashPosition + dashDirection * dashSpeed, dashProgress));
    }
}

I tried interpolating the NetworkRigidbody2d component to all the available interpolation data sources(Auto, snapshots, predicted, no interpolation) in photon fusion.

Initially, I have tried DashMove to run locally. But while dashing, the state authority overrides the player position especially on the client. So I made it an RPC. The thing with RPCs is that they’re not tick based instead time based. Potentially, this jerkiness is coz of trying to dash using an RPC.

Later I have also tried making the state authority to handle the dash locally which should be synced across all the clients. But it is snapping the player to the final dash position.

What is the right approach?

New contributor

levitate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật