Skip to content

DominicBg/GenericCharacterController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenericCharacterController

A generic character with multiple states like "Idle, Walk, Running, Air"

Add a new state

  1. In the class PlayerState, add the new state to the enum public enum State { Idle, Walk, Running, Air, NewState };

  2. Create a new class called PlayerStateNewState which inherit from PlayerState

  3. In the inspector, locate the "stateTransform" of the StateMachine and add your new state as a component

  4. In PlayerStateMachine, in the function InitialiseStateDictionary(), add InitialiseState(PlayerState.State.NewState, stateTransform.GetComponent());

  5. In other state, call SetState(PlayerState.NewState) when you see fit!

Behaviour

Each time a new State is set, the previous will call "OnEnd()", so don't use "OnEnd()" to leave the currentState. The new state will call "OnStart()"

Addition

"PlayerInput" will convert your input to match the view of the camera. Pressing "Up" will make you walk forward considering the camera view.

"PlayerAnimationListener" will bind animations with state, this is helpful if you want your code in the state to stay clean and cohesive.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages