-
Notifications
You must be signed in to change notification settings - Fork 0
Glossary of Important Methods
This page provides an overview of commonly overridden methods when creating custom bros, organized by functionality.
Awake() is called once when the Bro is created, before Start(). You can use this method for initializing any variables / custom projectiles your bro uses, but generally I prefer to keep most of my initialization in the Start() method.
Note that your bro's sprite / gunsprite / avatar materials won't be loaded by BroMaker yet when Awake() is called. If you want to store those, in case you wanted to swap to different materials, then you'll want to place that in Start() instead.
Start() is called once when the Bro is created, after Awake(). You can use this method to set up any additional sprites that your bro uses, custom projectile prefabs, your bro's meleeType (important to have custom melee functions called), or any other variables that need initializing. If you want to store the original sprite materials, in case you'd like to swap them later, you should make sure you call base.Start() first, to allow BroMaker to load your sprites.
Update() runs every frame during gameplay. You can use this method to handle ongoing logic like state management, timers, and any mechanics that need constant updating.
Note: Since this runs every frame, avoid heavy calculations. Use flags and timers to optimize performance.
LateUpdate() is called every frame after all Update() methods have completed. This makes it useful for positioning objects that need to follow your bro or ensuring visual elements stay synchronized after physics calculations.
OnDestroy() is called when your bro GameObject is being destroyed. Override this to clean up any spawned objects, release held references, or update any global state that tracks your bro.
RecallBro() is called when your bro is despawned but not destroyed (such as when switching bros in campaign mode). Use this for cleanup that should happen during temporary removal, similar to OnDestroy() but without permanent destruction.
PreloadAssets() is a BroMaker-specific method that runs during mod initialization. Use this to load custom sprites, sounds, and other assets into memory before any bros are created.
Note: As a static method, you cannot access instance variables here. Store loaded assets in static variables for later reference.
PrefabSetup() is called when BroMaker creates your bro's prefab. You can use this to obtain references to vanilla game assets, particularly audio clips from existing bros.
HarmonyPatches() is where you apply any Harmony patches specific to your bro. Harmony patches allow you to modify vanilla game methods without replacing them entirely.
UIOptions() allows you to add custom options to the mod menu for your bro. Return an array of strings describing each option, and BroMaker will create the appropriate UI controls.
Return: An array of option descriptions, or an empty array if no options are needed.
The primary fire system follows this call hierarchy:
- Player presses fire button →
StartFiring()
called once - While holding fire →
RunFiring()
called every frame - Player releases fire →
StopFiring()
called once -
RunFiring()
typically calls →UseFire()
when ready to shoot -
UseFire()
typically calls →FireWeapon()
to create projectile
Additionally:
-
RunGun()
runs every frame to handle gun animations -
SetGunPosition()
is called automatically to position the gun sprite -
SetGunSprite()
can be used to change gun visuals
StartFiring() is called once when the fire button is first pressed. Use this to initialize firing state, whether that's starting a charge timer, beginning a continuous effect, or setting up firing animations.
RunFiring() is called every frame while the fire button is held. This method handles ongoing firing logic like charging, burst timing, or continuous effects. It typically calls UseFire()
when ready to shoot.
StopFiring() is called when the fire button is released or when firing is interrupted. Use this to clean up any firing state, stop continuous effects, or reset charge timers.
ReleaseFire() is called when the fire button is released, before StopFiring(). This method is rarely needed but can be useful for weapons that fire on button release or need to track how long the button was held.
UseFire() triggers a single shot. By default, it cancels melee and calls FireWeapon(). Override this to add conditions before firing or implement alternate fire modes.
Note: This is typically called by RunFiring(), not directly by input.
FireWeapon() creates the actual projectile or attack effect. The parameters provide the spawn position and initial velocity.
Parameters:
-
x, y
- World position to spawn the projectile (accounts for gun position) -
xSpeed, ySpeed
- Initial velocity for the projectile
Override this to spawn custom projectiles, create special patterns, or implement entirely different attack types.
RunGun() is called every frame to handle gun sprite animations. Use this for muzzle flashes, charging effects, or weapon switching animations. The base game uses gunFrame to track animation progress.
SetGunPosition() adjusts where the gun sprite appears relative to your bro. The offsets are added to the base position. This is called automatically by the game during rendering.
SetGunSprite() changes which gun sprite is displayed. Most bros set this.gunSprite
directly instead of overriding this method.
Parameters:
-
spriteFrame
- Animation frame to display -
spriteRow
- Gun sprite row to use
ActivateGun() and DeactivateGun() show or hide the gun sprite. Override these when you need to control gun visibility, such as for melee weapons that only appear during attacks.
The melee system follows this pattern:
- Player presses melee →
SetMeleeType()
determines melee type -
StartCustomMelee()
initializes the melee attack - During melee →
AnimateCustomMelee()
andRunCustomMeleeMovement()
run each frame -
AnimateCustomMelee()
calls →PerformCustomMeleeAttack()
at the damage frame - Melee ends naturally or →
CancelMelee()
if interrupted
StartCustomMelee() is called when the melee button is pressed. Use this to initialize your melee attack, set the melee type, and configure damage values. You can implement different melee attacks based on your bro's current state or equipment.
Note: For custom melee to work properly, you need to set this.meleeType
in Start() to something other than MeleeType.Knife
.
SetMeleeType() is called before starting melee to determine the melee type based on your bro's state (standing, jumping, dashing). Override this if you need different melee behaviors in different states.
AnimateCustomMelee() is called every frame during melee to handle animations. Use this to progress through animation frames and call PerformCustomMeleeAttack() at the appropriate frame to deal damage.
RunCustomMeleeMovement() is called every frame during melee to control movement. Use this to add dashing attacks, limit movement, or apply special physics during melee.
CancelMelee() is called when melee is interrupted by other actions. Use this to clean up any melee state, stop sounds, or reset visual effects.
ThrowBackMook() is called when your bro throws an enemy. Override this to add special effects or behaviors to thrown enemies.
The special ability system follows this pattern:
- Player presses special →
PressSpecial()
called (sets usingSpecial = true) -
UseSpecial()
is called to consume ammo and trigger the effect -
AnimateSpecial()
handles the animation frames - Player releases special →
ReleaseSpecial()
called (rarely used)
PressSpecial() is called when the special button is first pressed. Use this to start charging abilities, trigger instant effects, or set up special states. The default behavior sets usingSpecial = true
.
UseSpecial() consumes special ammo and executes the special ability. By default, this throws a grenade. Override to implement custom abilities like spawning objects, transforming, or applying buffs.
AnimateSpecial() handles the animation frames for special abilities. Use this to animate throwing motions, transformations, or charging effects.
ReleaseSpecial() is called when the special button is released. In the base game, this is mostly unused, other than BroLander who uses it to allow holding down special to continuously use specials. Most custom bros won't need to override this.
SpecialAmmo is a property that tracks special ability ammunition. Override the getter/setter to implement custom ammo systems or infinite specials.
Jump() is called when a jump is initiated. The wallJump
parameter indicates if this is a wall jump. Override this to modify jump behavior, cancel states, or add effects.
AirJump() handles double jumps or other mid-air jump abilities. Override this to add special mechanics during air jumps.
AirDashLeft() and AirDashRight() are called to initiate directional air dashes. Override these to implement custom dash attacks or movement abilities.
RunAirDashing() is called every frame during an air dash. Use this to maintain dash effects or update dash physics.
RunLeftAirDash() and RunRightAirDash() handle the physics and damage for directional air dashes. Override to customize dash behavior and effects.
ApplyFallingGravity() is called every frame when the bro is falling. Override this to modify gravity, implement gliding mechanics, or disable gravity during special abilities.
CalculateMovement() is called every frame to determine movement velocity based on player input. Override to modify movement speed or restrict movement during special states.
RunMovement() is called every frame to apply movement and update the bro's position. Override to implement custom movement mechanics or update attached objects.
AddSpeedLeft() and AddSpeedRight() add horizontal velocity to the bro. Override these to limit or modify speed during special moves or abilities.
Land() is called when the bro touches ground after falling. Override to handle landing effects, reset air abilities, or implement special landing mechanics.
ChangeFrame() is called when the animation frame updates. Use this to handle frame-specific logic, cancel abilities during certain animations, or prevent animation conflicts.
SetGestureAnimation() is called when the bro performs gestures like flexing. Override to handle gesture-specific behavior or cancel ongoing abilities.
AnimateInseminationFrames() handles special victory animations after boss defeats. This method is rarely overridden.
AnimateFakeDeath() plays a death animation without actually killing the bro. Use this for transformation sequences or fake-out mechanics.
AnimateWallAnticipation() is called before the bro grabs a wall. Override to cancel abilities or prepare for wall grab animations.
AnimateWallDrag() is called while the bro slides down walls. Override to enable special actions or animations during wall slides.
CanCheckClimbAlongCeiling() determines if the bro can grab and climb along ceilings. Override to enable ceiling mechanics.
AttachToZipline() is called when the bro grabs a zipline. The parameters specify the zipline position. Override to handle cleanup or state changes when attaching.
StartPilotingUnit() is called when the bro enters a vehicle. Override to handle cleanup or state changes when entering vehicles.
public override void Damage(int damage, DamageType damageType, float xI, float yI, int direction, MonoBehaviour damageSender, float hitX, float hitY)
Damage() is called when the bro takes damage. Override to implement damage resistance, trigger transformations, or create special reactions to specific damage types.
Parameters:
-
damage
- Amount of damage to apply -
damageType
- Type of damage (Bullet, Fire, Crush, etc.) -
xI, yI
- Knockback force -
direction
- Direction of impact (-1 left, 1 right) -
damageSender
- The object that caused the damage -
hitX, hitY
- World position of impact
Death() is called when the bro dies. Override to handle special death behavior, release held objects, or trigger transformations instead of dying.
Parameters:
-
xI, yI
- Death knockback velocity -
damage
- The damage object that killed the bro
Gib() is called when the bro is violently killed (exploded). Override for special gibbing effects or alternate death animations.
CheckInput() processes player input. Override to detect custom input patterns or implement special controls.
CheckFacingDirection() updates which direction the bro faces based on input. Override to lock facing direction during certain abilities.
PressHighFiveMelee() is called when the high-five button is pressed. Override to trigger special abilities or handle detachment from surfaces.
AlertNearbyMooks() is called when the bro makes noise that should alert enemies. Override to disable alerts during stealth abilities or modify alert behavior.
This documentation reflects the methods commonly used in custom bro development. Always refer to the base game's implementation for default behavior.
If you have questions or need help with creating custom bros, you can join the Free Lives Discord Server and post your questions in the bf-mods channel.