Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using deltaTime in movement system? #78

Open
Shadowblitz16 opened this issue Oct 11, 2024 · 1 comment
Open

Using deltaTime in movement system? #78

Shadowblitz16 opened this issue Oct 11, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@Shadowblitz16
Copy link

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
        });
    }
}
@ClxS
Copy link

ClxS commented Oct 14, 2024

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.

@genaray genaray added the documentation Improvements or additions to documentation label Oct 23, 2024
@genaray genaray moved this to Todo in Arch Roadmap Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Todo
Development

No branches or pull requests

3 participants