CC Package and Physics
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Unity.Burst;
|
||||
using Unity.Entities;
|
||||
using Unity.NetCode;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Bridges replicated <see cref="PlayerInput"/> + data-driven <see cref="EffectiveCharacterStats"/> into
|
||||
/// the CC processor's per-tick <see cref="CharacterControl"/>. Replaces the M5 <c>PlayerMoveSystem</c>:
|
||||
/// instead of writing PhysicsVelocity, it writes the desired world velocity that
|
||||
/// <see cref="CharacterProcessor"/> lerps toward inside the fixed-step character update. Runs in
|
||||
/// <see cref="PredictedSimulationSystemGroup"/> after <see cref="StatRecomputeSystem"/> (fresh MoveSpeed)
|
||||
/// and before the predicted fixed-step group (where the character physics steps). Derived purely from
|
||||
/// replicated input + recomputed stats → identical on server, owning client, and across rollback.
|
||||
/// Filtered to <see cref="Simulate"/> for predicted ghosts only.
|
||||
/// </summary>
|
||||
[UpdateInGroup(typeof(PredictedSimulationSystemGroup))]
|
||||
[UpdateAfter(typeof(StatRecomputeSystem))]
|
||||
[BurstCompile]
|
||||
public partial struct PlayerControlSystem : ISystem
|
||||
{
|
||||
[BurstCompile]
|
||||
public void OnUpdate(ref SystemState state)
|
||||
{
|
||||
foreach (var (control, input, stats) in
|
||||
SystemAPI.Query<RefRW<CharacterControl>, RefRO<PlayerInput>, RefRO<EffectiveCharacterStats>>()
|
||||
.WithAll<Simulate>())
|
||||
{
|
||||
control.ValueRW.MoveVelocity =
|
||||
CharacterControlMath.DesiredMovement(input.ValueRO.Move, stats.ValueRO.MoveSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user