{"id":16140514,"url":"https://github.com/anthonyec/godot_state_machine","last_synced_at":"2025-07-21T19:36:15.885Z","repository":{"id":176123770,"uuid":"653578111","full_name":"anthonyec/godot_state_machine","owner":"anthonyec","description":"🤖 Simple code only finite state machine for Godot","archived":false,"fork":false,"pushed_at":"2023-11-25T00:04:25.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-13T00:26:37.299Z","etag":null,"topics":["addon","fsm","godot","state"],"latest_commit_sha":null,"homepage":"","language":"GDScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anthonyec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-14T10:15:40.000Z","updated_at":"2024-01-19T18:21:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0b4e659-58ca-4cef-99f6-fde54e31981e","html_url":"https://github.com/anthonyec/godot_state_machine","commit_stats":null,"previous_names":["anthonyec/godot_state_machine"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyec%2Fgodot_state_machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyec%2Fgodot_state_machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyec%2Fgodot_state_machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyec%2Fgodot_state_machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthonyec","download_url":"https://codeload.github.com/anthonyec/godot_state_machine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247528392,"owners_count":20953412,"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","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":["addon","fsm","godot","state"],"created_at":"2024-10-09T23:52:58.853Z","updated_at":"2025-04-06T18:25:26.162Z","avatar_url":"https://github.com/anthonyec.png","language":"GDScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Godot State Machine\n\nSimple code only state machine that's is originally based off [GDQuest's implementation](https://www.gdquest.com/tutorial/godot/design-patterns/finite-state-machine/).\n\n## Features (or problems)\n\n- States are nodes\n- Nested states, but only 1 level (parent and child)\n- Support for deferred state transitions\n- Bulk of the logic is in one file (under 200 lines)\n\n## Usage\n\n### State node\n```gdscript\n# Invoked when transitioning to this state. Used for setup and\n# handling any paramaters passed from the previous state.\nfunc enter(params: Dictionary) -\u003e void:\n\tpass\n\n# Invoked when transitioning to another state. Generally used\n# for cleanup, it also will yield if `await` is used inside of it.\nfunc exit() -\u003e void:\n\tpass\n\n# Equivalent to `_ready`.\nfunc awake() -\u003e void:\n\tpass\n\n# Equivalent to `_process`.\nfunc update(delta: float) -\u003e void:\n\tpass\n\n# Equivalent to `_physics_process`.\nfunc physics_update(delta: float) -\u003e void:\n\tpass\n\n# Equivalent to `_input`.\nfunc handle_input(event: InputEvent) -\u003e void:\n\tpass\n\n# Handle messages that have been sent to the state machine.\n#\n# This is usefull for when something external wants to change\n# the state, but avoids forefully transitioning by using\n# `transition_to` directly.\nfunc handle_message(title: String, _params: Dictionary) -\u003e void:\n\tpass\n\n```\n\n### Transition to a state\n\n```gdscript\n# Transition to a state using the name of the node.\nstate_machine.transition_to(\"Jump\")\n\n# Additional parameters can be passed along to the next state, which helps avoids globals.\nstate_machine.transition_to(\"Jump\", {\n  \"height\": 100\n})\n```\n\n### Deffered transition\n\n```gdscript\n# This will queue a state change, waiting for one physics frame to have been completed before transitioning.\nstate_machine.deffered_transition_to(\"Jump\")\n\n# Parameters are passed as a callback to ensure that when the transition occurs, any variable references in the params are the latest values.\nstate_machine.deffered_transition_to(\"Jump\", func():\n  return {\n    \"velocity\": velocity\n  }\n)\n```\n\n### Transition to the previous state\n\n```gdscript\n# Transition to whatever previous state invoked the current state.\nstate_machine.transition_to_previous_state()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonyec%2Fgodot_state_machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonyec%2Fgodot_state_machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonyec%2Fgodot_state_machine/lists"}