Friday Night Funkin' Cookbook
Friday Night Funkin' CookbookAdvancedScripted Playable Characters

Scripted Playable Characters

Reading time: 1 minute

This chapter will walk you through the process of adding a script to a Playable Character, and giving examples of the kind of custom behavior which can be implemented with this functionality.

Start by creating a scripted class file with the .hxc extension (in the mods/mymod/scripts/players if you want to keep things organized).

// Remember to import each class you want to reference in your script!
import funkin.ui.freeplay.charselect.PlayableCharacter;

// Choose a name for your scripted class that will be unique, and make sure to specifically extend the PlayableCharacter class.
// This class's functions will override the default behavior for the character.
class WhittyPlayer extends PlayableCharacter {
    public function new() {
        // The constructor gets called whenever the character is spawned.
        // The constructor takes one parameter, which is the player ID for the player you are applying the script to.
        super('whitty');
    }

    // Add override functions here!
}

You can then add override functions to perform custom behavior.

Custom Unlock Behavior

The most important thing to override here is the isUnlocked function, which lets you define whether the player can access the given character in Freeplay.

  // An example of overriding the `isUnlocked` function.
  // This is the logic for Pico, which requires checking the completion status of a given story week.
  // You can put any logic you want here.
  override function isUnlocked():Bool {
    return Save.instance.hasBeatenLevel('weekend1');
  }

Contributors:
Cameron Taylor
kade-github
Kolo
Last modified:
Created:
Category:  Advanced