[FUSION] How to make movement script without any Fusion Input System?

Hello, can someone explain how this guy made his multiplayer working without any Fusion Input system?

When I made similar code as on this video, I got my player stuck and don’t want to move without lags, sometimes it’s jittering.
One difference from this video: I have used Rigidbody2D for movement and not the CharacterController.

My Movement code:

    private void FixedUpdateNetwork()
    {
        if (input.x != 0 || input.y != 0)
        {
            rb.velocity = input * currentSpeed;
        }
        else
        {
            rb.velocity = new Vector2(0, 0);
        }
    }

When using physics in Fusion we recommend using the Physics Addon. Replace the NetworkTransform on the NetworkObject with a NetworkRigidbody2d and add a RunnerPhysicsSimulate2D to your NetworkRunner and the jitter should disappear.

1 Like

Now it works much much better! Thank you! But i have another problem here:
When second player [client] joined → when he moves → he see that his player is very laggy.
At the same time, on the first player side [host] it looks good and player#2 have smooth moving.

[UPD] Everything works smooth only on the Server/Host side.
[UPD2] When changed Physics Timing to “Update”, it works almost perfect but the player can’t interact with the Soccer Ball and other players (which positions is calculated on the server side).

What can be the problem here?
I’m attaching my physics settings.

[Runner]
image
[Player]
image

In Host/Server Mode you want the PhysicsAuthority to be Fusion and the PhysicsTiming as FixedUpdateNetwork.

I believe your problem is the following.

  1. you are predicting the player object on the client
  2. you are not running a client physics simulation (it is set to Disabled)

This leads to a discrepancy. There’s two solutions:

  1. Set Client Physics Simulation to True. This will run the physics prediction loop. It will make your movement feel immediate but it costs a lot of CPU.
  2. Keep the physics server only and in your object add a script that in override Spawned() checks If InputAuthority is set to true and if so sets runner.SetIsSimulated(Object, false);

Both solutions should fix the jittering. If not, you can try to put the visuals on a separate child object (just the mesh renderer not the physics colliders) and then assign that object as the interpolation target on the NetworkRigidbody2d.

1 Like

Your second solution is worked, it’s almost removed the lags/discrepancies.
But for some reason now I see that my player moves with small delay after I pressing the buttons.
When I compared with the Host player and the client one, it feels really different.

What do you think about it?

Also, I found it is not very clear for me: when Host disconnected → other players is being destroyed / not synced.
How I can prevent it? In Photon PUN the game just choose other Host (master), but in Fusion it is not like this?

With the second solution you will get delay between inputs and movement. This is because this is using a server/host authoritative solution. So the client will send the inputs to the host, the host will move the object > the client will then get the position from the host and update the visuals. This adds a lot of delay (1 RTT).

If you want something that is more similar to PUN (client authority in a cloud room) use Fusion in Shared Mode. This is by far the easiest mode to use but comes with similar limitations as PUN.

If you want host/server mode but want it to be reactive you need to implement prediction (1. I suggested above)

Is there any perfect solution for a soccer game?
Yes - I need to have client authority.
The main thing is i need to sync the ball across all players, but in that case i have this delay issue… (in the host mode)
And I don’t know how to sync it in Shared mode correctly, the second player can’t interact with the ball the same way as first player.

If it’s impossible to make this sync on Shared mode, then how to predict the player in the Host mode?

Any physics based real-time competitive game is a huge challenge. This is not a simple problem it is incredibly hard.

In shared mode you will have to request StateAuthority over a ball so this does not feel great as it adds delay.

For this reason we generally recommend Photon Quantum for anything real-time and physics based. Quantum has a much higher learning curve than Fusion but once you understand it physics just work out of the box. E.g. our QBall sample: Quantum 3 QBall | Photon Engine

Or we he have a soccer sample using 2d gameplay (3d graphics) as part of our paid circle support program: Quantum 2 Soccer | Photon Engine

Yes, I see that Quantum can be the solution of my problem but i’m not sure that it is convenient to work with.
I see that it has it’s own physics and code, also it’s almost unlinked from Unity.
And it says that there’s no NetCode but actually all game code now is a NetCode and it makes it even harder to develop the game.

Also, want to ask, is Quantum rooms/servers is on Photon cloud, so i don’t need to run my own dedicated server?
And would like to know why there’s only few youtube videos about it (tutorials i mean)?

Actually, I would like to leave it as it is, with Fusion.
Only one thing for now: How to create rooms in Host mode?

As far I understand, now it’s only 1 big room (If i will use dedicated server).
Even if i need to host in on Dedicated server, i can’t imagine the Room/Session system there.

I need something like in shared mode, can you explain how you made it there, on your cloud?
Or maybe it’s possible to use Unity’s Relay system for multiplayer in the Host mode?