{"id":18458841,"url":"https://github.com/wooshiidev/unity-fsm","last_synced_at":"2025-08-02T11:06:31.860Z","repository":{"id":49366306,"uuid":"367513393","full_name":"WooshiiDev/Unity-FSM","owner":"WooshiiDev","description":"A powerful lightweight Finite State Machine for Unity, taking full advantage of editor.","archived":false,"fork":false,"pushed_at":"2024-03-24T10:49:11.000Z","size":39,"stargazers_count":46,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-08T05:34:35.539Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WooshiiDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-15T01:10:31.000Z","updated_at":"2024-12-05T02:48:26.000Z","dependencies_parsed_at":"2022-09-19T06:20:43.166Z","dependency_job_id":null,"html_url":"https://github.com/WooshiiDev/Unity-FSM","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/WooshiiDev/Unity-FSM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WooshiiDev%2FUnity-FSM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WooshiiDev%2FUnity-FSM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WooshiiDev%2FUnity-FSM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WooshiiDev%2FUnity-FSM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WooshiiDev","download_url":"https://codeload.github.com/WooshiiDev/Unity-FSM/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WooshiiDev%2FUnity-FSM/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268378749,"owners_count":24240896,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T08:20:25.934Z","updated_at":"2025-08-02T11:06:31.821Z","avatar_url":"https://github.com/WooshiiDev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1 align=\"center\"\u003e  \n Unity Finite State Machine (FSM)\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eA powerful lightweight Finite State Machine for Unity, taking advantage of reflection and the editor.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"https://unity3d.com/get-unity/download\"\u003e\n \u003cimg src=\"https://img.shields.io/badge/unity-2018.4%2B-blue.svg\" alt=\"Unity Download Link\"\u003e\n \u003ca href=\"https://github.com/WooshiiDev/HierarchyDecorator/blob/master/LICENSE\"\u003e\n \u003cimg src=\"https://img.shields.io/badge/License-MIT-brightgreen.svg\" alt=\"License MIT\"\u003e\n\u003c/p\u003e\n  \n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#about\"\u003eAbout\u003c/a\u003e •\n  \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e •\n  \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e •\n  \u003ca href=\"#support\"\u003eSupport\u003c/a\u003e\n\u003c/p\u003e\n\n## About\nThis Unity FSM is extremely lightweight but carried by the power and utility of the Unity Editor. \n\nRather than handling states through ScriptableObjects or MonoBehaviours, all states are light classes that are all collected and edited within the FSM Manager. From the FSM Manager, custom default values can be assigned without requiring any form of recompile or edit to the original script.\n\n\u003cp align=\"center\"\u003e\n \u003cimg src=\"https://i.imgur.com/z9hMYBU.png\" alt=\"Unity Download Link\"\u003e\n\u003c/p\u003e\n\nAll public fields that are within the state will be shown and can be edited from the manager. When an instance changes to that state, all set values will be passed over. \n\n**Use case examples will be soon added to the repository!**\n\n## Usage\n\nBecause of it's extremely light system, there are no transition behaviour or conditions you see in other state machines. It is purely a state only system. On each compile, new created states will be recognized by the state manager, so they can also be edited.\n\n### Scene Setup\n\nRunning any FSM is extremely simple - all you require is a manager component so that the states can be retrieved:\n![image](https://user-images.githubusercontent.com/31889435/118346401-01050d80-b533-11eb-9c60-1a0c232d74fd.png)\n\nAnd for instances, just add a State Machine to the required game objects. From here you can select the state the instance will start with, and see runtime information on the current state and the previously ran one.\n![image](https://user-images.githubusercontent.com/31889435/118346394-f5b1e200-b532-11eb-96cc-a08a93762e14.png)\n\n### State Creation 101\n\nTo create a state, simply extend the base state or any custom state made:\n\n```cs\npublic class ExampleState : State\n{\n\n}\n```\n\nStates will be grouped in the FSM Manager based on their namespace. This decision was chosen as it was the most convenient and structured way to group states based on the structure of the project.\n\nFor example, if `MoveState` was in `States.Character.Move`, this would appear in the \"Move\" category in the Manager:\n\n![image](https://user-images.githubusercontent.com/31889435/118346093-082b1c00-b531-11eb-900b-0d8b85f88b0c.png)\n\nCategories will always take the final term in the namespace.\n\n### State Methods\n\nThe following methods are the standards in each state:\n\n```cs\n/// \u003csummary\u003e\n/// Called when entering the state. Use for getting references or setting up behaviour\n/// \u003c/summary\u003e\npublic virtual void OnEnter()\n{\n\n}\n\n/// \u003csummary\u003e\n/// Called when exiting the state.\n/// \u003c/summary\u003e\npublic virtual void OnExit()\n{\n\n}\n\n/// \u003csummary\u003e\n/// Update tick\n/// \u003c/summary\u003e\npublic virtual void Tick(float delta)\n{\n    age += Time.deltaTime;\n}\n\n/// \u003csummary\u003e\n/// Fixed update tick\n/// \u003c/summary\u003e\npublic virtual void FixedTick(float delta)\n{\n    fixedAge += Time.fixedDeltaTime;\n}\n\n/// \u003csummary\u003e\n/// Late update tick\n/// \u003c/summary\u003e\npublic virtual void LateTick(float delta)\n{\n\n}\n\n/// \u003csummary\u003e\n/// Debug update tick\n/// \u003c/summary\u003e\npublic virtual void DebugTick(float delta)\n{\n\n}\n```\n\n`OnEnter` - Will be called once when the state is created.\n\n`OnExit` - Will be called once when the state is exited.\n\n\nEach update method has a delta parameter that will pass Time.DeltaTime. For FixedUpdate this turns into FixedDeltaTime.\n\n`Tick(float delta)` - Represents Update\n\n`FixedTick(float delta)` - Represents FixedUpdate\n\n`LateTick(float delta)` - Represents LateUpdate\n\n`DebugTick(float delta)` - An additional update method for OnDrawGizmos. Normally used for debugging.\n\n### Switching States\n\nSwitching states is done through accessing the FSM MonoBehaviour on the GameObject:\n\n```cs\n// Inside a State Class...\npublic override void Tick(float delta)\n{\n  // If the state is older than or equal to 10 seconds\n  if (age \u003e= 10)\n  {\n    parent.SetState(new OtherState());\n  }\n}\n```\n\n### Switching State Parents\n\nIf for any reason states require a new parent, you can do so through the `SetParent(StateMachine parent)` method.\n\n## Installation\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/WooshiiDev/Unity-FSM/releases/download/v1.0.0/Unity-FSM-v1.0.0.unitypackage\"\u003eUnity Package\u003c/a\u003e •\n \u003ca href=\"https://github.com/WooshiiDev/Unity-FSM/archive/refs/tags/v1.0.0.zip\"\u003eZip\u003c/a\u003e •\n \u003ca href=\"https://github.com/WooshiiDev/Unity-FSM/archive/refs/tags/v1.0.0.tar.gz\"\u003eTar\u003c/a\u003e \n\u003c/p\u003e\n\nYou can also clone the repository through git using the following:\n```git clone https://github.com/WooshiiDev/Unity-FSM.git```\n\n## Support\nPlease submit any queries, bugs or issues, to the [Issues](https://github.com/WooshiiDev/Unity-FSM/issues) page on this repository. All feedback and support is massively appreciated as it not only helps me, but allows the projects I work on to be improved.\n\nReach out to me or see my other work through:\n\n - Website: https://wooshii.dev/\n - Email: wooshiidev@gmail.com;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooshiidev%2Funity-fsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwooshiidev%2Funity-fsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooshiidev%2Funity-fsm/lists"}