|
1 | 1 | # Creating a Friday Night Funkin' Mod - Scripted Characters
|
2 | 2 |
|
3 | 3 | This chapter will walk you through the process of adding a script to a Character, and giving examples of the kind of custom behavior which can be implemented with this functionality.
|
| 4 | + |
| 5 | +Start by creating a scripted class file with the `.hxc` extension (in the `mods/mymod/scripts/characters` if you want to keep things organized). |
| 6 | + |
| 7 | +```haxe |
| 8 | +// Remember to import each class you want to reference in your script! |
| 9 | +import funkin.play.character.SparrowCharacter; |
| 10 | +
|
| 11 | +// Choose a name for your scripted class that will be unique, and make sure to specifically extend the correct character class. |
| 12 | +// SparrowCharacter is the one to use for XML-based characters. |
| 13 | +// This class's functions will override the default behavior for the character. |
| 14 | +class WhittyCharacter extends SparrowCharacter { |
| 15 | + public function new() { |
| 16 | + // The constructor gets called whenever the character is spawned. |
| 17 | + // The constructor takes one parameter, which is the song ID for the song you are applying the script to. |
| 18 | + super('whitty'); |
| 19 | + } |
| 20 | +
|
| 21 | + // Add override functions here! |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +You can then add override functions to perform custom behavior. |
| 26 | + |
| 27 | +## Character Classes |
| 28 | + |
| 29 | +If you use a different animation type for a character, you need to specify a different base script class, otherwise the character will fail to load. |
| 30 | + |
| 31 | +- `funkin.play.character.SparrowCharacter` is used for characters that have Sparrow spritesheet animations. |
| 32 | +- `funkin.play.character.MultiSparrowCharacter` is used for characters that have several Sparrow spritesheet animations to combine into one character. |
| 33 | +- `funkin.play.character.PackerCharacter` is used for characters that have Packer spritesheet animations. |
| 34 | +- `funkin.play.character.AnimateAtlasCharacter` is used for characters that have Adobe Animate texture atlases. |
| 35 | +- `funkin.play.character.BaseCharacter` has empty stubs for all the rendering and animation handlers, and is only useful for people who want to reimplement their character's animation system by hand. |
0 commit comments