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

More Samples/Explaination On Class-based architecture #40

Open
LaoBowen opened this issue Feb 24, 2024 · 1 comment
Open

More Samples/Explaination On Class-based architecture #40

LaoBowen opened this issue Feb 24, 2024 · 1 comment

Comments

@LaoBowen
Copy link

Hi~ Can we have more samples and explaination on Class-based architectures? Like:

Using Class-based architecture to rebuild the GuardAI Example.

Derived from StateBase/ActionState/State and their difference

How te create Custom Actions in such class instead of ".AddAction("OnFixedUpdate", () => { })"

Thank you!

@jarrednorrisdev
Copy link

jarrednorrisdev commented May 11, 2024

I also am struggling to figure out how to elequontly implement an OnFixedLogic action in a state that inherits StateBase without changing the implementation of the package source.

EDIT:
Upon further exploration of the code I found the ActionState class which may be what i was looking for. It might be worth adding mention of this to the Class architecture section of the documentation/readme.

Here is my understanding of how I might be able to do this. Are there any reasons why this might be a good or bad way to implement this functionality?

public abstract class ActionStateWithFixed : ActionState
{
    protected ActionStateWithFixed(bool needsExitTime, bool isGhostState = false)
        : base(needsExitTime, isGhostState)
    {
        AddAction("OnFixedLogic", OnFixedLogic);
    }

    public abstract void OnFixedLogic();
}
public void FixedUpdate()
    {
        MovementStateMachine.OnAction("OnFixedLogic");
    }

PS This asset is super cool, thank you for sharing!

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