CC Package and Physics
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Unity.CharacterController;
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Tunables for the top-down kinematic character (M5b: Unity Character Controller package). Twin-stick /
|
||||
/// planar: NO jump, NO air control, NO gravity, NO view pitch. The per-tick target speed comes from the
|
||||
/// data-driven <see cref="EffectiveCharacterStats.MoveSpeed"/> via <see cref="PlayerControlSystem"/>; this
|
||||
/// component only carries the smoothing sharpness + step/slope handling the CC processor needs. Authored
|
||||
/// on the player prefab by <c>PlayerCharacterAuthoring</c>. Not a ghost — movement replicates through the
|
||||
/// owner-predicted LocalTransform (re-simulated on the owner, interpolated on remotes).
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct CharacterComponent : IComponentData
|
||||
{
|
||||
/// <summary>How quickly RelativeVelocity is lerped toward the target velocity on the ground.</summary>
|
||||
public float GroundedMovementSharpness;
|
||||
|
||||
/// <summary>Step/slope handling params (defaults; planar ground so mostly inert).</summary>
|
||||
public BasicStepAndSlopeHandlingParameters StepAndSlopeHandling;
|
||||
|
||||
public static CharacterComponent GetDefault()
|
||||
{
|
||||
return new CharacterComponent
|
||||
{
|
||||
GroundedMovementSharpness = 15f,
|
||||
StepAndSlopeHandling = BasicStepAndSlopeHandlingParameters.GetDefault(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Per-tick, NON-replicated control for the CC processor, derived each predicted tick from the replicated
|
||||
/// <see cref="PlayerInput"/> by <see cref="PlayerControlSystem"/>. Derived (not authored, not a ghost): a
|
||||
/// pure function of replicated input + recomputed stats, so it reproduces identically on server, owning
|
||||
/// client, and across rollback re-simulation.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct CharacterControl : IComponentData
|
||||
{
|
||||
/// <summary>World-space desired velocity (already scaled by MoveSpeed, Y == 0). The processor lerps
|
||||
/// RelativeVelocity toward this each tick.</summary>
|
||||
public float3 MoveVelocity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user