JetController is a state machine which gives an actor access to different mechanics and movements, including walking, turning, jumping, bouncing, dashing, knockback, climbing ladders, and more. It works with JetState components attached to the same GameObject.
public void SetState(JetState _state, bool canInterruptSelf = false)
Attempts to set the current state of the controller. _state is the new state being set. canInterruptSelf represents whether or not _state can be initiated even if the existing state is the same as the one you’re attempting to change it to. In a majority of situations, canInterruptSelf should be false; one notable exception is for jumping, where multi-jumping allows subsequent jumps to initiate even if the actor is already in the Jump state.
public void SetAxis(Vector2 _axis)
This sets the movement direction that JetController will attempt to move in. The _axis argument lets you pass a Vector2 which sets both the X and Y movement directions. Both the X and Y values should be floats ranging from -1.0 to 1.0, with 0.0 representing no attempted movement in a direction and -1.0 and 1.0 representing full movement in a direction.
public void Stun()
Stops the JetController from moving. Can be reversed by setting the isStunned variable on JetController back to true.
public string StateID()
Returns the name of the currentState that the JetController is currently in.
public void SetToAlive()
This is automatically called by any attached JetActor. It sets values needed for the JetController to be considered “alive” again after the attached JetActor was dead, including enabling its JetPhysics and reverting its JetState to DefaultState.
public void SetToDead()
Automatically called by an attached JetActor when the JetActor dies. This ends the movements of all currently active states and begins DeathState.
public void EndAllStates()
This method ends the movements for every single JetState this JetController governs.
public void SetStateToDefault(bool canInterruptSelf = false)
This cancels out of the currentState of the JetController and sets it to either DefaultState, if the actor is grounded, or FallingState, if the actor is airborne. This is commonly called when a state ends. If canInterruptSelf is true, it can re-initialize the default/falling state, complete with restarting its animation, even if default/falling is already the current state.
public void CancelTurn()
If the JetController is in the middle of a turn, this cancels it.
public void FaceDirection(Direction.Horizontal _direction)
This checks to see if the JetController can face a direction, and if so, it turns to face that direction using the Turn() method.
public virtual void Turn()
This plays the appropriate turning animation slotted under Turn Animations, auto-detecting whether to use the grounded or aerial AnimationClip, and then scales the JetController’s Transform property so its X value is either -1 (facing left) or 1 (facing right).
public virtual void AnimateGravityFlip()
This allows you to play an AnimationClip when gravity is reversed. The AnimationClip is slotted into Turn Animations under gravityFlipAnimation.
public virtual void AnimateEnable()
This allows you to play an AnimationClip when this JetController first becomes active via JetActor’s SetController method. The AnimationClip is slotted into Animations under onEnabledAnimation.
public bool CanChangeDirection()
Returns true if the JetController is capable of changing directions. It will return false if knockback is currently active, if the actor is currently attacking and the Attack disallows direction changes, or if the JetController’s currentState disallows direction changes.
public bool IsOveriddenByCrouch()
Determines if the actor is crouching, and if that crouch takes precedence over another attempted action.
public void Knockback(Direction.Horizontal _direction)
If the JetController has an attached KnockbackState and that KnockbackState is enabled, this calls Begin() on it, knocking the actor back in the direction passed in.
public float GravityScaleMultiplier()
This returns 1.0 if the attached JetPhysics has normal gravity, and -1.0 if the attached JetPhysics has reversed gravity. This is most commonly used for physics equations that depend on the direction of gravity, such as resolving falling or jumping.
public Slots slots
Here, you can slot various base-level things JetController uses, such as its attached JetActor and Animator.
public Animations animations
AnimationClips for the basic animations JetController uses.
public TurnAnimations turnAnimations
AnimationClips for the grounded, crouching and aerial turn animations. Also includes an AnimationClip which can be played while gravity is reversing.
public AudioClips audioClips
Here, you can slot the AudioClips that play when the JetController enters various states.
public float overrideMaxFallSpeed
If this is greater than 0, it will override the gravitySettings.maxFallSpeed value on the attached JetPhysics.
public float aerialPeak
The highest point this reaches during a jump or fall. Used internally by JetController to determine the distance of a fall.
public int framesSinceDrop
The number of frames since the player dropped from a ladder. Used primarily to prevent actors from dropping from a ladder and immediately jumping on the same frame.
public bool isEnabled
If isEnabled is False, this will not update movement for its JetStates.
public bool isTurning
Whether the Controller is in the middle of turning left > right, or vice versa.
public bool isKnockbackActive
Whether the Controller currently has knockback active.
public bool isStunned
In a stunned state with minimal input allowed, but not being damaged or knocked back.
public Vector2 axis
//The directional axis this will move in if no input is slotted; -1.0f is left, 1.0f is right, 0.0f is neutral.
public bool isDashing
Whether a Dash is currently active.
public JetState currentState
The current JetState being updated by this Controller.
public JetState previousState
The previous JetState.
public Direction direction
The direction the JetController is facing.