Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Hierarchical State Machine for Unity

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

IntoTheDev/Hierarchical-State-Machine-for-Unity

Repository files navigation

Hierarchical State Machine for Unity. Most likely I will rewrite it multiple times in the future but for now it suits my needs.

TODO

  • Rewrite everything

How to Install

Git Installation

If you have Git on your computer, you can open Package Manager indside Unity, select "Add package from Git url...", and paste link https://github.com/IntoTheDev/Hierarchical-State-Machine-for-Unity.git

or

Open the manifest.json file of your Unity project. Add "com.intothedev.ai": "https://github.com/IntoTheDev/Hierarchical-State-Machine-for-Unity.git"

Simple Example:

public class TestStateMachine : HierarchicalStateMachine
{
	[SerializeField] private float _timeInPatrol = 1f;
	[SerializeField] private float _timeInIdle = 3f;

	protected override StateMachine Setup()
	{
		var patrolState = new PatrolState(transform, speed: 5f, randomizeStartSpeed: true);
		var emptyState = new Empty();

		var stateMachine = new StateMachine()
			.Configure(startState: patrolState)
			.AddTransition(patrolState, emptyState, new WaitFor(waitFor: 1f), reversed: false)
			.AddTransition(emptyState, patrolState, new WaitFor(waitFor: 3f), reversed: false);

		return stateMachine;
	}
}

Releases

No releases published

Languages