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

Fixed Update for Entitas #402

Closed
Shmewwww opened this issue Apr 26, 2017 · 9 comments
Closed

Fixed Update for Entitas #402

Shmewwww opened this issue Apr 26, 2017 · 9 comments

Comments

@Shmewwww
Copy link

Shmewwww commented Apr 26, 2017

Hi! Can you give me advice how create system which executes in FixedUpdate;
I found not good solution for this:

using Entitas;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class SomeFixedUpdateSystem : IInitializeSystem {

    public SomeFixedUpdateSystem(Contexts contexts) {
        
    }

    public void Initialize() {
        GameControlls.Instance.StartCoroutine(FixedExecute());
    }

    IEnumerator FixedExecute() {
        while(true) {
            
            // do something
            yield return new WaitForFixedUpdate();
        }
    }
}
@FNGgames
Copy link

Possible solution : Create a second set of systems in you game controller (e.g. Systems _fixedSystems = new Systems().Add() ...). Call _fixedSystems.Execute() from within FixedUpdate().

@sschmid
Copy link
Owner

sschmid commented Apr 26, 2017

Hey! Simply create systems that you execute OnFixedUpdate()

Match-One - GameController calls execute OnUpdate(). You own the systems, you can call them whenever is best for you.

I can also imagine having 2 sets of systems, one executed on Update, the other on fixed update.

Hope that helps

@sschmid
Copy link
Owner

sschmid commented Apr 26, 2017

@FNGgames you're just too fast ;)

@aefreedman
Copy link

(put this in the wiki) cough

@VladislavKostin
Copy link

VladislavKostin commented Apr 26, 2017

Having some systems executed in Update and some in FixedUpdate was my first solution, but then doesn't it create problems with input or other things that have one frame life cycles and have to be cleaned up at the end of the frame?

For example, I create Input event entities in Input systems, and I clean them up on Cleanup(). If have systems in the Fixed update they won't receive the input, right? Or did I do something wrong?

So instead I just Update my static FixedTime component on every FixedUpdate() and have my systems react to it.

@aefreedman
Copy link

aefreedman commented Apr 26, 2017

It depends on how you implement your input system.

Ref. the execution order of Unity events FixedUpdate() always occurs before Update(), even if executed multiple times.

Edit: removed incorrect info so I don't confuse people.

@Shmewwww
Copy link
Author

Okay!!! Create new system for fixed update doing well!! Thx

@VladislavKostin
Copy link

@aefreedman But If I create and cleanup (destroy) input entities inside an Update() than why does it matter if they are reactive? When are reactive systems triggered? I thought reactive systems are triggered on Execute() and when it happens they receive all the accumulated changes from the collector.

@aefreedman
Copy link

@VladislavKostin yeah I'm wrong don't mind me lol

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

No branches or pull requests

5 participants