Synced input on general behaviours

erre
erre
Hi!

I have a problem with Synced input on general behaviours.

I saw that on TrueSyncManager is executed this code:
if (generalBehaviours != null)
{
foreach (TrueSyncManagedBehaviour bh in generalBehaviours)
{
if (bh != null && !bh.disabled)
{
bh.OnSyncedInput();
}
}
}
So I assume that the input is taken by all clients on general behaviours.

But in SyncedUpdate, is executed this
TrueSyncInput.CurrentSimulationData = null;
if (generalBehaviours != null)
{
foreach (TrueSyncManagedBehaviour bh in generalBehaviours)
{
if (bh != null && !bh.disabled)
{
bh.OnSyncedUpdate();
instance.scheduler.UpdateAllCoroutines();
}
}
}
So the Synced Update is called on general behaviours with CurrentSimulationData = null.

Is it correct?

In general behaviours OnSyncedInput, I would like to write something like:
int value = x;
byte key = s_Base + myPhotonId;
TrueSyncInput.SetInt (key, value );

so every player should write a different key.

Does it make sense?

Thank you for your support.

Best regards,
Andrea.

Comments

  • Hello @erre,

    Andrea you are right, OnSyncedInput should be only called in player behaviours, that call in general behaiours can lead to a bug. The OnSyncedUpdate call it is correct, you can do some logic in every frame, but with no direct access to local player input (same reason as OnSyncedInput). We will include a better way to get players inputs, so you could take some action in OnSyncedUpdate of general behaviours.
  • Great, it would be very helpful to have a way to use the input also on general behaviours. They could be used in order to collect commands from different players.
  • I believe having the TrueSyncBehavior and an Interface that can implemented + a way to register the behaviours will suffice. But in general the recommendation is to have TrueSync behaviors to collect input from all players...

    I normally create a specific player prefab just to collect/queue input, and apply/distribute/generate actions on the SyncedUpdate, calling methods on normal behaviours for other player objects (that I spawned/instantiated from this controller prefab).