#GhostField CodeGen generates compilation error

1 messages · Page 1 of 1 (latest)

steady agate
#

Hi all,

I'm following the tutorial for netcode for entities (third person player) here 1. It was all working good until I updated (from 6000.2.1) to the most recent 6000.2.10.

I'm seeing that having multiple GhostFields under a single struct causes a code generation compilation error. For example:

[GhostComponent]
public struct ThirdPersonPlayer : IComponentData
{
    [GhostField]
    public Entity ControlledCharacter;
    // [GhostField]  // -- uncomment this to repro 
    public Entity ControlledCamera;
}

The error:

A local variable or function named 'ghostComponent' is already defined in this scope

The generated code:

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static void CopyToSnapshotGenerated(in GhostSerializerState serializerState, ref Snapshot snapshot, ref Player.Components.NetcodePlayer component)
        {       
                ...
                if (serializerState.GhostFromEntity.TryGetComponent(component.ControlledCharacter, out var ghostComponent))
                {   ...  }
                if (serializerState.GhostFromEntity.TryGetComponent(component.ControlledCamera, out var ghostComponent))
                {   ...  }
        }

The problem is the ghostComponent declared twice in the same scope. Any idea how to get the code generation to play nice?

GitHub

Sample projects for the Unity.CharacterController package - Unity-Technologies/CharacterControllerSamples