8000 GitHub - Pyxus/fray at v1.0.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pyxus/fray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fray

Fray Logo

Godot version License

📖 About

Fray is an addon for the Godot Game Engine that provides tools which aid in the development of action / fighting game combat. If your project requires changes in combatant state corresponding to button presses, input buffering, handling complex player inputs, or hitbox management then you may benefit from using Fray!

Demo gif

Demo showcasing input processing and state mangaement.

✨ Core Features

Modular Design

Fray is divided into 3 modules: State, Input, and Collision. These modules act independent of one another and only communicate through string identifiers. This means you are not locked in to using Fray's tools and can run your own solutions along side it by interpreting these strings in your current setup.

Combat State Management

Fray provides a combat state machine that allows you to keep track of a fighter's state and automatically transition to new states based on the player's inputs. Transitions in the state machine can be enabled and disabled through code or the animation player; through this Fray supports the implementation of chaining. For example, If transitions are allowed early into an attack animation then the attack can, in effect, be canceled into a new attack.

State machines can be defined declaratively using the included builder classes.

combat_state_machine.add_situation("on_ground", CombatSituationBuilder.new()\
    .transition_button("idle", "attack1", {input = "attack_button"})\
    .transition_button("attack1", "attack2", {input = "attack_button"})\
    .start_at("idle")\
    .build()
)

Input Buffering

Inputs fed to fray's combat state machine are buffered allowing a player to queue their next action before the current action has finished. Buffering is an important feature in action / fighting games as without it players would need frame perfect inputs to smoothly perform a sequence of actions.

func _on_FrayInput_input_detected(input_event: Fray.Input.FrayInputEvent):
	if input_event.is_just_pressed():
		combat_state_machine.buffer_button(input_event.input, input_event.pressed)

Complex Input Detection

Fray provides a component based input builder, and sequence analyzer for handling the 'complex' inputs featured in many fighting games such as directional inputs, motion inputs, charged inputs, and sequence inputs.

Composite inputs can be defined declaratively using the CompositeInputFactory class.

const CIF = Fray.Input.CompositeInputFactory

# Binds are used as the 'leafs' of composite input component trees.
FrayInputMap.add_bind_action("ui_right", "right")
FrayInputMap.add_bind_action("ui_down", "down")

# Describes a c
89F2
ombination input which changes based on what side the player is on.
FrayInputMap.add_composite_input("down_forward", CIF.new_conditional()\
    .add_component("", CIF.new_combination_async()\
        .add_component(CIF.new_simple(["down"]))\
        .add_component(CIF.new_simple(["right"])))\
    .add_component("on_right", CIF.new_combination_async()\
        .add_component(CIF.new_simple(["down"]))\
        .add_component(CIF.new_simple(["left"])))\
    .is_virtual()\
    .build()
)

Sequence inputs can be defined using the SequenceList class, and then registered to the SequenceAnalyzer. The sequence analyzer can then be fed inputs and will emit a signal if any matches are found.

var sequence_list := SequenceList.new()

sequence_list.add("236p", SequencePath.new()\
    .then("down").then("down_forward").then("forward").then("punch"))

# An alias sequence can be created by adding a new path with the same sequence name
sequence_list.add("214p", SequencePath.new()\
    .then("down").then("forward").then("punch"))
func _on_FrayInput_input_detected(input_event: Fray.Input.FrayInputEvent):
	sequence_analyzer.read(input_event)

Hitbox Management

Fray provides a template hitbox which is an Area node with an attributes property. Attributes can be extended to determine the properties of the hitbox they are attached to. In addition, Fray provides tools for managing these hitboxes in the form of hit states. Hit states can control which hitbox child node is active through a single property in the inspector which can be keyed in animations for easy syncing.

Tree view of hitbox management

View of hit state inspector

📦 Installation

  1. Clone or download a copy of this repository.
  2. Copy the contents of addons/ into your res://addons/ directory.
  3. Enable Fray - Combat Framework in your project plugins.

If you would like to know more about installing plugins see the Official Godot Docs.

📚 Documentation

📃 Credits

0