RexController 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 RexState components attached to the same GameObject.
public void SetState(RexState _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 RexController 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 RexController from moving. Can be reversed by setting the isStunned variable on RexController back to true.
public string StateID()
Returns the name of the currentState that the RexController is currently in.
public void SetToAlive()
This is automatically called by any attached RexActor. It sets values needed for the RexController to be considered “alive” again after the attached RexActor was dead, including enabling its RexPhysics and reverting its RexState to DefaultState.
public void SetToDead()
Automatically called by an attached RexActor when the RexActor dies. This ends the movements of all currently active states and begins DeathState.
public void EndAllStates()
This method ends the movements for every single RexState this RexController governs.
public void SetStateToDefault(bool canInterruptSelf = false)
This cancels out of the currentState of the RexController 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 RexController is in the middle of a turn, this cancels it.
public void FaceDirection(Direction.Horizontal _direction)
This checks to see if the RexController can face a direction, and if so, it turns to face that direction using the Turn() method.
public void OnAttackComplete()
Used by Attack to notify the controller when an attack has ended. This is in turn used to notify each RexState and to allow them to react accordingly to the attack ending.
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 RexController’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 RexController first becomes active via RexActor’s SetController method. The AnimationClip is slotted into Animations under onEnabledAnimation.
public bool CanChangeDirection()
Returns true if the RexController 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 RexController’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 RexController 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 RexPhysics has normal gravity, and -1.0 if the attached RexPhysics 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 void PlaySingleAnimation(AnimationClip animation)
Plays an AnimationClip one time. This AnimationClip will override other animations that the RexController or its associated RexStates will attempt to play for its duration.
public void TemporarilyDisableOneWayPlatforms
Disables collision with one-way platforms, allowing the actor to drop through; automatically re-enables them shortly thereafter.
public Slots slots
Here, you can slot various base-level things RexController uses, such as its attached RexActor and Animator.
public Animations animations
AnimationClips for the basic animations RexController 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 RexController enters various states.
public float overrideMaxFallSpeed
If this is greater than 0, it will override the gravitySettings.maxFallSpeed value on the attached RexPhysics.
public float aerialPeak
The highest point this reaches during a jump or fall. Used internally by RexController 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 RexStates.
public bool isTurning
Whether the Controller is in the middle of turning left > right, or vice versa.
public bool isOverridingAnimationInProgress
Whether or not a one-time animation is currently overriding other animations that might attempt to play.
public bool isKnockbackActive
Whether the Controller currently has knockback active.
public float stunDuration
The amount of time the actor will be stunned when stun is activated.
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 RexState currentState
The current RexState being updated by this Controller.
public RexState previousState
The previous RexState.
public Direction direction
The direction the RexController is facing.