ThrowComponent - acrimi/Raven GitHub Wiki

Extends StatefulComponent, ChildLinkedComponent

ThrowComponent is an extension of StatefulComponent that represents a throwing action. While the component is "active", a continuous force will be applied to its target entity along the 2d plane and optionally along the z axis. The target will have its TransformComponent detached, if necessary, and can also have a hit code added to its HitBoxComponent to become a projectile.

The component does not support custom enter/exit states, and cannot be initialized in a non-inactive state. Instead, the component always has a single exit state named "followThrough" that has a configurable duration parameter.

Configuration

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

Key Type Description
force float The horizontal force that will be applied to thrown entity in the direction of the thrower's orientation while the component is active. Measured relative to gl units (mass * glUnits/second^2). Defaults to 0.
verticalForce float The force along the z axis that will be applied to thrown entity while the component is active. Measured relative to gl units (mass * glUnits/second^2). Defaults to 0.
hitCode int An optional hit code that will be set on the thrown entity's HitBoxComponent, if present.
followThrough float The duration, in seconds, of the the follow through exit state. Defaults to 0.
duration* float The duration, in seconds, of the "active" state for this component. Defaults to -1, which is treated as infinite duration.

* from StatefulComponent

Example:

"ThrowComponent": {
  "duration": 0.3,
  "followThrough": 0.1,
  "force": 13000,
  "verticalForce": 4000,
  "hitCode": 2
}

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.
childId** int The id of the child entity referenced by this component, or -1 if no entity is currently linked
hasChild** boolean True if an entity is currently referenced by this component, false otherwise

* from StatefulComponent
** from ChildLinkedComponent

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