36 lines
1.7 KiB
C#
36 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using Unity.CharacterController;
|
|
using Unity.Entities;
|
|
using Unity.NetCode;
|
|
|
|
namespace ProjectM.Simulation
|
|
{
|
|
/// <summary>
|
|
/// Ghost-variant registration for the kinematic character (M5b). <see cref="CharacterInterpolation"/> is
|
|
/// presentation-only fixed-step smoothing that must exist ONLY on predicted clients: on the server it
|
|
/// would interfere with LocalToWorld, and on interpolated remote ghosts it would double up with netcode's
|
|
/// own snapshot interpolation. <c>BakeCharacter</c> adds it to every prefab version, so we force it
|
|
/// predicted-client-only here.
|
|
/// <para>
|
|
/// We deliberately do NOT override the default variants for <c>LocalTransform</c> or
|
|
/// <c>PhysicsVelocity</c> (the CC sample's DontSerializeVariant on LocalTransform is global and would
|
|
/// break the non-character ghosts in this project — projectiles, dummies, pickups — which rely on stock
|
|
/// LocalTransform replication). The character's position therefore replicates via the normal
|
|
/// owner-predicted LocalTransform path, like every other ghost.
|
|
/// </para>
|
|
/// </summary>
|
|
public sealed partial class CharacterGhostVariantsSystem : DefaultVariantSystemBase
|
|
{
|
|
protected override void RegisterDefaultVariants(Dictionary<ComponentType, Rule> defaultVariants)
|
|
{
|
|
defaultVariants.Add(typeof(CharacterInterpolation), Rule.ForAll(typeof(CharacterInterpolation_GhostVariant)));
|
|
}
|
|
}
|
|
|
|
[GhostComponentVariation(typeof(CharacterInterpolation))]
|
|
[GhostComponent(PrefabType = GhostPrefabType.PredictedClient)]
|
|
public struct CharacterInterpolation_GhostVariant
|
|
{
|
|
}
|
|
}
|