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 diff update rates for Systems #6

Open
cchandel opened this issue Nov 8, 2021 · 2 comments
Open

Using diff update rates for Systems #6

cchandel opened this issue Nov 8, 2021 · 2 comments

Comments

@cchandel
Copy link

cchandel commented Nov 8, 2021

Hi,
Is there a way I can use different updates rates for systems ?

For eg, the movement system might need updating every 33 ms, but say the inventory system might only need to be updated on an event like the player firing a gun. Another system - say fuel system - might need updating only every 5 secs.

How do I achieve this?

Thanks

@zllangct
Copy link
Owner

zllangct commented Nov 8, 2021

func (f *FakeSystem) Update(e ecs.Event) {
    f.elapse += e.Delta
    if f.elapse < time.Second * 5 {
        return
    } else {
        f.elapse = 0
    }
    
    //TODO something you want to do

}

@cchandel
Copy link
Author

cchandel commented Nov 8, 2021

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants