RollComponent - acrimi/Raven GitHub Wiki

Extends StatefulComponent

RollComponent is an extension of StatefulComponent that represents a rolling action of an entity. While in the "active" state, a configurable jumping force will be applied for a given amount of time, followed by a period of time in which the entity is considered "in the air" and friction will be ignored. Invincibility frames can also be configured to for any portion of the roll's duration.

Configuration

When used inside the components block, the initial state of the component can be configured with the following parameters:

Key Type Description
jumpForce float The force (in glUnits/s2*kg) that will be applied to the entity during the initial jumping phase of the "active" state. Defaults to 0.
jumpTime float The duration (in seconds) of the initial jumping phase of the "active" state. Defaults to 0.
airTime float The duration (in seconds) of the "airborne" phase of the "active" state. During this time, no friction will be applied to the entity's movement. Defaults to 0.
invincibility object|string An optional object to configure the invincibility frames that coincide with the roll action. As a shorthand, the literal value "full" can be provided to have the entity become invincible for the whole duration of the roll.
      start float The starting timestamp (in seconds) relative to the beginning of the "active" state when the entity will become invincible. If omitted, or if the value is less than 0, the entity will not experience any invincibility.
      duration float The duration (in seconds) of the entity's invincibility. If omitted, the entity will be invincible from "start" until the end of the "active" state.
duration* float The duration, in seconds, of the "active" state for this component. Defaults to -1, which is treated as infinite duration.
enterStates* (string|object)[] An array of states that will be passed through when going from the "inactive" state to the "active" state. Each state can be defined as either an object with a single key value pair corresponding the state's name and duration, or as a string representing the state name. States defined as a string will have an infinite duration. The array values can be heterogenous.
      [stateName]* float The key represents the name of this state and the value is the duration, in seconds. For infinite duration, use a value of -1
exitStates* (string|object)[] An array of states that will be passed through when going from the "active" state to the "inactive" state. Each state can be defined as either an object with a single key value pair corresponding the state's name and duration, or as a string representing the state name. States defined as a string will have an infinite duration. The array values can be heterogenous.
      [stateName]* float The key represents the name of this state and the value is the duration, in seconds. For infinite duration, use a value of -1
initialState* string The state the component will start in. Must be one of "inactive", "active", or any of the custom states provided via enterStates or exitStates. By default, the component will start in the "inactive" state. Setting a different initial state will not cause events to fire for entering that state.
isActive* boolean Equivalent to passing "active" to initialState. Defaults to false.

* from StatefulComponent

Examples:

"RollComponent": {
  "duration": 0.8,
  "jumpForce": 50000,
  "jumpTime": 0.2,
  "airTime": 0.4
}
"RollComponent": {
  "duration": 0.8,
  "jumpForce": 50000,
  "jumpTime": 0.2,
  "airTime": 0.4,
  "invincibility": "full"
}
"RollComponent": {
  "duration": 0.8,
  "jumpForce": 50000,
  "jumpTime": 0.2,
  "airTime": 0.4,
  "invincibility": {
    "start": 0.2
  }
}
"RollComponent": {
  "duration": 0.8,
  "jumpForce": 50000,
  "jumpTime": 0.2,
  "airTime": 0.4,
  "invincibility": {
    "start": 0.2,
    "duration": 0.5
  }
}

Properties

The following properties are readable by property accessors (eg render state and persistence definitions):

Key Type Description
isActive* boolean Whether or not the current state is "active"
isInactive* boolean Whether or not the current state is "inactive"
state* string The name of the current state
progress* float The percentage, from 0 to 1, of how much time has elapsed for the current state relative to its duration (elapsedTime / duration). If the current state has an infinite duration, this value is always 0.

* from StatefulComponent

⚠️ **GitHub.com Fallback** ⚠️