Hey Folks,
I initially found this issue trying to network the com.unity.charactercontroller package but in the process of bisecting the issue, can also see the problem in just a vanilla physics setup.
I have a cube that I spawn per player, and simple WASD controls that apply angular impulses to the cube.
[UpdateInGroup(typeof(GhostInputSystemGroup))]
// Input collecting
public partial class ThirdPersonPlayerInputsSystem_Dupe : SystemBase
{
protected override void OnCreate()
{
RequireForUpdate<FixedTickSystem.Singleton>();
RequireForUpdate(SystemAPI.QueryBuilder().WithAll<ThirdPersonPlayerInputs>().Build());
}
protected override void OnUpdate()
{
uint fixedTick = SystemAPI.GetSingleton<FixedTickSystem.Singleton>().Tick;
foreach (var playerInputs in SystemAPI.Query<RefRW<ThirdPersonPlayerInputs>>())
{
playerInputs.ValueRW.MoveInput = new float2();
playerInputs.ValueRW.MoveInput.y += Input.GetKey(KeyCode.W) ? 1f : 0f;
playerInputs.ValueRW.MoveInput.y += Input.GetKey(KeyCode.S) ? -1f : 0f;
playerInputs.ValueRW.MoveInput.x += Input.GetKey(KeyCode.D) ? 1f : 0f;
playerInputs.ValueRW.MoveInput.x += Input.GetKey(KeyCode.A) ? -1f : 0f;
}
}
}
//Apply angular impulse
[UpdateInGroup(typeof(PredictedFixedStepSimulationSystemGroup), OrderFirst = true)]
public partial struct ThirdPersonPlayerFixedStepControlSystem_Dupe : ISystem
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<FixedTickSystem.Singleton>();
state.RequireForUpdate(SystemAPI.QueryBuilder().WithAll<ThirdPersonPlayerInputs, PhysicsVelocity, PhysicsMass>().Build());
}
public void OnDestroy(ref SystemState state)
{ }
public void OnUpdate(ref SystemState state)
{
foreach (var (playerInputs, pv, pm) in SystemAPI.Query<RefRW<ThirdPersonPlayerInputs>, RefRW<PhysicsVelocity>, PhysicsMass>().WithAll<Simulate>())
{
pv.ValueRW.ApplyAngularImpulse(pm, playerInputs.ValueRW.MoveInput.y * new float3(0, 0, 0.1f) + playerInputs.ValueRW.MoveInput.x * new float3(0.1f, 0, 0));
}
}
}
What I’m seeing is that in editor, the impulses are reasonable and the movement is smooth as expected. But in the build (Dedicated linux server + WebGL w/ Custom WebRTC transport) the cube has erratic behavior. Almost like there are 10x the number impulses applied. The same behavior existed on the character controller, in the build the character moved extremely fast.
I saw in another thread there are potentially some bugs server-side with tick rate? Any ideas?
The only other thing I can think of is my custom transport but I would expect many other things to be broken if I messed something up at the transport layer.