User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 15 of 15

Thread: What is the most effective way to create a State Machine in Fusion 2.5?

  1. #11
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    845
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    You shouldnt activiate deactive groups, instead use an alterable value or flags to determine the state.

    E.g. if flag 0 determines idle and flag 1 is chase.

    Player attacks goblin
    -Turn goblin flag 1 on
    -Turn gobling flag 0 off

    Goblin flag 1 is on
    Goblin flag 0 is off
    -Always look at player

    Goblin flag 0 is on
    Goblin flag 1 is off
    -Goblin movement stop (or whatever you want it do when idle)

    You could probably use AlterableStrings too instead of flags and then check the string what it says.

  2. #12
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    Personally, I use an AlterableValue called "eState" and set it to a value to determine its state. A value of "0" means the enemy is making a decision based on a random pool. Then I change the value to correspond with an action (ie 1 = idle, 2 = walk, 3 = attack, etc). You can also use an AlterableString so it is easier to read the enemy state, but that is generally a little more cpu intensive if you plan to have a lot of enemies going at once. The thing to always remember is that if you don't use groups, you generally need a condition on each line that checks the eState value.

  3. #13
    Clicker Fusion 2.5 MaciOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2017
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zip2kx View Post
    You shouldnt activiate deactive groups, instead use an alterable value or flags to determine the state.
    <snip>
    Why do you say this? I rely heavily on activating and deactivating groups as my game progresses through various stages and conditions. It's a really handy way to make sure only the code I want at any given time can run. It also helps organize my code in bite-sized chunks. I'm assuming it's also a great performance helper, as the system doesn't have to check all the events that aren't currently relevant (since the groups those are in have been deactivated).
    And in fact one place I'm using this is in a state machine.
    So I'm curious why I shouldn't activate/deactivate groups?
    In a related note: if I deactivate a group in an event within the group, will the following events in the group still execute on that frame or does it stop that group processing immediately?

  4. #14
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,558
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fleisl View Post
    In a related note: if I deactivate a group in an event within the group, will the following events in the group still execute on that frame or does it stop that group processing immediately?
    No, they won't execute.

  5. #15
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    845
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fleisl View Post
    Why do you say this? I rely heavily on activating and deactivating groups as my game progresses through various stages and conditions. It's a really handy way to make sure only the code I want at any given time can run. It also helps organize my code in bite-sized chunks. I'm assuming it's also a great performance helper, as the system doesn't have to check all the events that aren't currently relevant (since the groups those are in have been deactivated).
    And in fact one place I'm using this is in a state machine.
    So I'm curious why I shouldn't activate/deactivate groups?
    In a related note: if I deactivate a group in an event within the group, will the following events in the group still execute on that frame or does it stop that group processing immediately?
    That works if you have one singular object. If you have more than one of the object, e.g. several enemies, it breaks their AI if they ALL dont get transfered to that new Group.

    Let's say you have groups called Idle (where the enemies just walk around not chasing anything) and Chase (when enemies get triggered they chase you). One of your enemies get triggered and you deactive the Idle Group, either everyone will get triggered and chase the player or if you use an alt value to check for trigger that lone one will chase and the others will just float away. That's because you made Fusion skip the entirety of the idle events.

    That's why you use flags or alt values to check for the objects condition.

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. re-installing Fusion on a new machine
    By JohnZ in forum Fusion 2.5
    Replies: 7
    Last Post: 9th August 2015, 04:30 PM
  2. Most effective way to switch characters
    By Warmachine in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 27th February 2014, 11:19 PM
  3. Machine license Fusion 2.5
    By join in forum Fusion 2.5
    Replies: 2
    Last Post: 16th February 2014, 08:56 PM
  4. Effective color fading
    By Jesse in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 24th October 2012, 03:38 PM
  5. Is LUA scripting required for effective AI?
    By Tactician in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 10th January 2011, 05:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •