Hi,
I am stuck at correctly updating the projectile I am shooting from my player.
I am updating it every OnUpdate:
[UpdateInGroup(typeof(PredictedSimulationSystemGroup))]
public partial struct NetworkProjectileSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
foreach (var (data, transform, entity) in SystemAPI.Query<NetworkProjectileData, LocalTransform>()
.WithEntityAccess().WithAll<Simulate>())
{
var newTransform = transform;
var newData = data;
var from = transform.Position;
var distance = data.stats.velocity * deltaTime;
newTransform.Position += newTransform.Forward() * distance;
ecb.SetComponent(entity, newTransform);
}
ecb.Playback(...)
}
}
However when I log out the data, only the server successfully updates the values of the projectile.
[Client] [124] [Entity(428:2)] Pos: 2.631364 → 2.763488
[Client] [125] [Entity(428:2)] Pos: 2.631364 → 2.763488
[Client] [126] [Entity(428:2)] Pos: 2.631364 → 2.659181
As you can see I am updating the positions in the loop, but in every prediction step the values are reset to their original value again.
The projectile prefab is set to OwnerPredicted, with HasOwner flag enabled.
The projectile gets instantiated in the client & server OnUpdate and the owner is correctly set.
Do you have any idea what I am missing to get this working?
I am working on the latest ECS 1.0