CC Package and Physics

This commit is contained in:
2026-06-02 08:56:26 -07:00
parent a5af81c8a8
commit 2ee30c01fd
37 changed files with 1295 additions and 142 deletions
@@ -0,0 +1,24 @@
using Unity.Mathematics;
namespace ProjectM.Simulation
{
/// <summary>
/// Pure, Burst-friendly math for top-down character control, factored out for EditMode unit testing
/// (no World/system needed). Maps a twin-stick move axis + speed to a planar world velocity.
/// </summary>
public static class CharacterControlMath
{
/// <summary>
/// Twin-stick move (x,y) on the XZ plane scaled by <paramref name="speed"/>. Input longer than unit
/// length is clamped (so diagonals aren't faster than cardinals); shorter is left proportional
/// (analog sticks). Returns a world velocity with Y == 0.
/// </summary>
public static float3 DesiredMovement(float2 move, float speed)
{
float lenSq = math.lengthsq(move);
if (lenSq > 1f)
move = math.normalize(move);
return new float3(move.x, 0f, move.y) * speed;
}
}
}