Projectiles timing not working on shared mode

Options
Sander
Sander
edited April 2023 in Fusion

Hello!

TLDR: A projectile spawned on the client, gets received on an earlier Tick on the masterclient. Resulting in projectile being behind the player (or standing still at the bullet slot)


Intro

I am trying to make fast and efficiently linked projectiles in Fusion shared mode by following the Projectile Essentials and Projectile Advanced Demos. But I ran into a problem when using shared mode for these projectiles specifically.

Both projectile demos only use host-client mode so I can't try and recreate the problem there to verify if I a doing something wrong or if this is just how fusion work.


The problem

(I will refer to MasterClient as Host, and other Clients will just be Client)

Like I mentioned above I am trying to use a projectile data buffer to visualize and sync projectiles across clients in shared mode and everything works except 1 case:

  • Host spawned projectile && Host visualized -> looks perfect
  • Host spawned projectile && Client visualized -> looks perfect*
  • Client spawned projectile && Client visualized -> looks perfect
  • Client spawned projectile && Host visualized -> Projectile never moves

*Host spawned and client visualized only works perfect due to the special calculated render time used in the demos:

float renderTime = Object.IsProxy ? Runner.InterpolationRenderTime : Runner.SimulationRenderTime;

Now the problem is that this render time does not seem to work when spawning the projectile on a client and trying to visualize it on the host.

Further more: the visualization on the host is actually received on an earlier tick than it has been sent on the client, which makes 0 sense to me. If you look at the image you can see that when the host spawn a projectile it is received on a later tick on the client. But when the client spawns a projectile it is received on an earlier tick on the host.

With all the test and experiments I conducted, it all resulted in timing issues when spawning something on Client and trying to visualize it on the Host. The client always seems to run ahead, which result in the visualization being behind the player or standing still at the barrel position

I have also tried to use latest server tick, that fixed the timing issues but it resulted in very jittery movement and projectile not spawning at the barrel position but way before the gun. A solution might be to use latest server tick and properly interpolated the visuals but that doesn't seem like an optimal solution.

Question

Is the fact that the client seems to run ahead on the host intended behaviour? If yes is there a way to avoid this or counter this effect when spawning projectile in a data buffer using Shared Mode? or is there another approach I could look at to make this work.


Extra Info

Below you will find some more code snippets on how I implement things but it should all be pretty similar to the Projectile demo code: