Netcode for Entities - IsFirstTimeFullyPredictingTick Always True

Hello everyone,

It’s probably due to a misconfiguration on my part, but I’m going crazy trying to solve a problem I can’t figure out. I’m developing a multiplayer point-and-click game. I’ve set up my player entity with the ghost component.


I’m using the new Input System. On the Client side, I have a SystemBase that captures mouse clicks.

private void ClickedMouse(InputAction.CallbackContext context)
{
    float2 mousePosition2D = Mouse.current.position.ReadValue();
    Logger.WriteLog($"Clicked Mouse at position: {mousePosition2D}");
    var PhysicsWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>().PhysicsWorld;
    var collisionWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>().CollisionWorld;
    var cameraEntity = SystemAPI.GetSingletonEntity<MainCameraInGameTag>();
    var mainCamera = EntityManager.GetComponentData<MainCameraInGame>(cameraEntity).value;


    float3 mousePosition = new float3(mousePosition2D.x, mousePosition2D.y, 100f);

    var worldPosition = mainCamera.ScreenToWorldPoint(mousePosition);

    if (_inputActions.Game.LeftClick.WasPressedThisFrame())
        inputEvent.Set(); // Imposta il flag IsSet a true

    var PlayerEntity = SystemAPI.GetSingletonEntity<PlayerInGameComponent>();
    EntityManager.SetComponentData(PlayerEntity, new PlayerInputComponent
    {
        StartRayClick = mainCamera.transform.position,
        EndRayClick = worldPosition,
        ActionClicked = inputEvent

    });

The IInputComponentData component correctly replicates the values I pass to it, and the action setup is also correct.
On the server side, I receive the component from an ISystem:

[UpdateInGroup(typeof(PredictedSimulationSystemGroup))]
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
[BurstCompile]
public partial struct ProcessInputSystem : ISystem
{
    [BurstCompile]
    public void OnCreate(ref SystemState state)
    {
        state.RequireForUpdate<NetworkTime>();
        state.RequireForUpdate<PlayerInputComponent>();
    }

    public void OnUpdate(ref SystemState state)
    {
        var networkTime = SystemAPI.GetSingleton<NetworkTime>();

        if (!networkTime.IsFirstTimeFullyPredictingTick)
            return;

        // Log dettagliato per monitorare il ciclo di previsione
        foreach (var (inputComponent, player, entity) in SystemAPI.Query<RefRW<PlayerInputComponent>, RefRO<PlayerInGameComponent>>().WithEntityAccess().WithAll<Simulate>())
        {
 
            Debug.Log($"NetworkTime   {entity}");

            bool isEnabled = inputComponent.ValueRO.ActionClicked.IsSet;
            //Debug.Log($"ProcessInputSystem Player: {player.ValueRO.PlayerID} :: IsSet {isEnabled} :: {state.World}");
            
            // Process the input here
            if (isEnabled)
            {
                Debug.Log($"NetworkTime Status: ServerTick={networkTime.ServerTick} frame {UnityEngine.Time.frameCount} IsFirstTimeFullyPredictingTick {networkTime.IsFirstTimeFullyPredictingTick}");
                // Esegui l'azione desiderata quando l'input è attivo
                //Debug.Log($"ProcessInputSystem Player " +
                //    $"{player.ValueRO.PlayerID} clicked {networkTime.IsFirstTimeFullyPredictingTick}");
            }
        }
    }

The input component is defined as follows:

using Unity.Mathematics;
using Unity.NetCode;

[GhostComponent]
public struct PlayerInputComponent : IInputComponentData
{
    [GhostField(Quantization = 0)] public float3 StartRayClick;
    [GhostField(Quantization = 0)] public float3 EndRayClick;
    [GhostField(Quantization = 0)] public InputEvent ActionClicked;
}

The problem is that when I click the mouse button, on the server the IsFirstTimeFullyPredictingTick flag is always set to true, causing the function to be called 24 times.


I can’t figure out what I’m doing wrong or how to move forward. Has anyone experienced the same issue or knows how I can fix it?

Your system is predicted but you’re running it only on Server (WorldSystemFilter). There’s no prediction on server, it’s authoritative, therefore prediction loop runs only once → IsFirstPredictingTick always returns true. You should run the predicted system on both Client and Server

I removed the WorldSystemFilter, and the result is an evenly distributed tick of true positives. I’m considering using an RPC for mouse clicks. Did I forget any other configuration?

I wouldn’t use RPC for mouse clicks, that’s not the intended way to use RPCs. It’s not clear what you’re expecting. Do you need to check for IsFirstFullyPredictingTick? Do you understand what it does?

I believe I understand that it tells me when a tick is fully predicted. My game is a point-and-click, and the mouse click will move my player. However, if I have more than one event for each click, I’ll end up triggering the movement method multiple times, which is not what I want. I wanted to trigger it only once, but at this point, I’m not sure how to proceed.

  1. Have a method that returns only true if Mouse was clicked down this frame
  2. Collect input in a system that runs in GhostInputGroup
  3. Reset your IInputComponentData each frame before collecting input (set component to default)
  4. Use InputEvent for one-off events (like mouse click)
  5. Set your IInputComponentData each frame, even if no input is given
  6. Run your movement system in a predicted group, run on both client & server
  7. If I’m not wrong, you shouldn’t need to check for IsFirstFullyPredictingTick

Okay, I’ll try to restructure everything following these points. It will take me a while, but I hope it works. I’ll let you know the result I get.