[Behavior] State Machine

0 favourites
  • 12 posts
From the Asset Store
Sprite set of animated modern war machines, include ground and air machines.
  • Hi,

    As first addon to build I've developed State Machine behavior, which tracks state and emits proper events if it changes.

    GitHub: github.com/anpur/c2-state-machine

    Download: goo.gl/SxoBYA

    With given functions you can decouple events which changes your object state and logic, how you object reacts on those changes.

    You can have several state machines per object, e.g. Mood ('sleeping', 'patrolling', 'fighting') and Weapon ('ready', 'aiming', 'firing', 'reloading').

    Events on specific state transitions can help you build animation more easily.

    For example: On Moster.Mood transition from sleep to attack set animation 'attack from lair'.

    Features:

      - In state condition: checks that machine in particular state.
      • On state change trigger: occurs when state changed.
      • On state entering trigger: occurs when entering particular state.
      • On state leaving trigger: occurs when leaving particular state.
      • On state transition trigger: occurs on transition from one particular state to another.
      • Set state action: set current state.
      • State expression: returns current state.
      • Previous state expression: return previous state.
      • Initial state property: to set initial state of machine.
      • Ignore same property: ignores attempts to set same state as current.

    I hope this behavior will be useful for someone <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    I'm still working on example project.

    P.S. - I realize, that this is not the first state machine addon, but I wanted to write it so much.

  • I had made one before.

  • Thanks for sharing this. The more choices the better

  • Thanks

  • AWESOME!

  • Features:

      - In state condition: checks that machine in particular state. - On state change trigger: occurs when state changed. - On state entering trigger: occurs when entering particular state. - On state leaving trigger: occurs when leaving particular state. - On state transition trigger: occurs on transition from one particular state to another. - Set state action: set current state. - State expression: returns current state. - Previous state expression: return previous state. - Initial state property: to set initial state of machine. - Ignore same property: ignores attempts to set same state as current.

    those expression look so awesome .. and simple to use.. i wander can i use it with a multiplayer system? i mean does it brake the exporting methods? or is it stable?

  • Made my C2 not even load. have to uninstall manually.

    ---------------------------
    Construct 2 Check failure
    ---------------------------
    Check failure!  This is probably a bug:
    
    ACE table: Expression ID duplicated in ACE table
    
    Condition: exp_ids.find(id) == exp_ids.end()
    File: c:\c2\source\exporters\html5\..\..\common\ERAHelpers.h
    Line: 269
    Function: void __cdecl era::ACETable::AddExpression(int,int,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,void (__cdecl *)(const class era::StaticResult **,int,class era::StaticEvaluation *))
    Build: release 214 (64-bit) checked
    Component: HTML5 exporter
    (Last Win32 error: 0)
    
    You are using a 'checked' release of Construct 2, intended for testing, which causes certain errors to be reported this way.  Hit Ctrl+C to copy this messagebox - it's useful information for the developers, so please include it with any bug reports!  Click 'Abort' to quit (unsaved data will be lost!),'Retry' to turn off messages for this session and continue, or 'Ignore' to continue normally.
    ---------------------------
    Abort   Retry   Ignore   
    ---------------------------
    [/code:dgruj2zo]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • jojoe It's a simple fix. In "edittime.js", there are two expressions with the ID 0, simply change the second entry to 1 and it will work.

  • Magistross,

    Thank you!

  • anpur Hey I have been meaning to stop by here and thank you for this plugin but it keeps slipping my mind. So, Thank you! Very easy and straightforward to use, very very helpful!

  • Hi! Thanks. It's all I need. Very helpful.

  • Hi anpur,

    I installed the bahaviour and the Contruct v220 broke.

    When I tried to start it showed me this message:

    [quote:1lfmhstu]---------------------------

    Construct 2 Check failure

    ---------------------------

    Check failure! This is probably a bug:

    ACE table: Expression ID duplicated in ACE table

    Condition: exp_ids.find(id) == exp_ids.end()

    File: c:\c2\source\exporters\html5\..\..\common\ERAHelpers.h

    Line: 269

    Function: void __cdecl era::ACETable::AddExpression(int,int,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,void (__cdecl *)(const class era::StaticResult **,int,class era::StaticEvaluation *))

    Build: release 220 (64-bit) checked

    Component: HTML5 exporter

    (Last Win32 error: 0)

    ---------------------------

    I had a hard time finding the problem. I need to delete the folder "anpur-state-machine" that was inside

    C:\Users[user]\AppData\Roaming\Construct2\behaviors after desinstalled and installed contruct twice.

    I don´t know if it was just with me.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)