CC Package and Physics
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user