解决旋转反向问题
This commit is contained in:
@@ -121,7 +121,7 @@ public sealed class ClientAuthoritativePlayerStateSnapshot
|
||||
|
||||
public int Hp { get; }
|
||||
|
||||
public Quaternion RotationQuaternion => Quaternion.Euler(0f, NormalizeDegrees(90f - Rotation), 0f);
|
||||
public Quaternion RotationQuaternion => Quaternion.Euler(0f, NormalizeDegrees(Rotation), 0f);
|
||||
|
||||
private static float NormalizeDegrees(float degrees)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public static class ClientGameplayInputFlow
|
||||
{
|
||||
PlayerId = playerId,
|
||||
Tick = tick,
|
||||
TurnInput = -input.x,
|
||||
TurnInput = input.x,
|
||||
ThrottleInput = input.z
|
||||
};
|
||||
return true;
|
||||
|
||||
@@ -222,7 +222,7 @@ public class MovementComponent : MonoBehaviour
|
||||
{
|
||||
Debug.Log(
|
||||
$"[Simulate] frame={Time.frameCount} input=({input.x:F2},{input.z:F2}) accum={_simulationAccumulator:F4}");
|
||||
ApplyTankMovement(-input.x, input.z, kServerSimulationStepSeconds);
|
||||
ApplyTankMovement(input.x, input.z, kServerSimulationStepSeconds);
|
||||
|
||||
//ApplyTankMovement(-input.x, input.z, kServerSimulationStepSeconds);
|
||||
|
||||
|
||||
@@ -174,6 +174,11 @@ namespace Network.NetworkHost
|
||||
IntegrateState(state, configuration.SimulationInterval);
|
||||
}
|
||||
|
||||
foreach (var state in statesByPeer.Values)
|
||||
{
|
||||
state.HasInputThisFrame = false;
|
||||
}
|
||||
|
||||
accumulatedBroadcastTime += configuration.SimulationInterval;
|
||||
while (accumulatedBroadcastTime >= configuration.BroadcastInterval)
|
||||
{
|
||||
@@ -362,6 +367,7 @@ namespace Network.NetworkHost
|
||||
state.LastAcceptedMoveTick = input.Tick;
|
||||
state.InputX = ClampInput(input.TurnInput);
|
||||
state.InputY = ClampInput(input.ThrottleInput);
|
||||
state.HasInputThisFrame = true;
|
||||
|
||||
if (state.InputY == 0f)
|
||||
{
|
||||
@@ -390,6 +396,16 @@ namespace Network.NetworkHost
|
||||
return;
|
||||
}
|
||||
|
||||
if (!state.HasInputThisFrame)
|
||||
{
|
||||
state.InputX = 0f;
|
||||
state.InputY = 0f;
|
||||
state.VelocityX = 0f;
|
||||
state.VelocityY = 0f;
|
||||
state.VelocityZ = 0f;
|
||||
return;
|
||||
}
|
||||
|
||||
var turnInput = ClampInput(state.InputX);
|
||||
var throttleInput = ClampInput(state.InputY);
|
||||
if (turnInput != 0f)
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace Network.NetworkHost
|
||||
|
||||
public float InputY { get; internal set; }
|
||||
|
||||
public bool HasInputThisFrame { get; internal set; }
|
||||
|
||||
public float Speed { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user