Arch.Extended
Arch.Extended copied to clipboard
Using deltaTime in movement system?
Your examples for BaseSystem doesn't include how to use deltatime
You can't just use deltaTime from the outer scope due to it not being valid in the lambda.
using Arch.Core;
using Arch.System;
using MineClone.Components;
namespace MineClone.Systems;
public class MovementSystem(World world) : BaseSystem<World, float>(world)
{
private QueryDescription _description = new QueryDescription().WithAll<Position, Velocity>();
public override void Update(in float delta)
{
base.Update(in delta);
World.Query(in _description, (ref Position position, ref Velocity velocity) =>
{
position.Value += velocity.Value * delta; // cannot use in parameter delta
});
}
}
Copy it to a local
float localDeltaTime = deltaTime;
And use that instead. I know it's arch here and not you, but in here at all feels strange.