Make your own BendsPack - mobends/MoBends GitHub Wiki

DEPRECATED: This documentation applies only to unsupported versions of Mo' Bends, before 1.0.0

Use the Mo' Bends Pack Editor

The official Mo' Bends Pack Editor is currently in development, and not yet available to the public as of writing this tutorial. There are other ways to make your own BendsPack though! Look below for more guidelines

How do I make a BendsPack (manually)?

A BendsPack is basically two files written in the JSON format. For the sake of the tutorial, I'll be making a custom jumping animation, something similiar to the Mario 64 jump:

Mario 64 jump gif

So I'll call my pack Mario Jump!. Clever name huh?

Meta file

The first file is the meta file. To create it, just create a text file and give it a .bendsmeta extension, so that Mo' Bends recognises the file properly. I'll call mine mariojump.bendsmeta.

(SIDENOTE) I usually give it a .json extension while I'm working on it, so that the text editor I'm using can format and syntax highlight the format a little better. When you finish working on it though, make sure to switch it back!

This is the format you want the file to be in:

{
    // This is a unique identifier for each pack. Make sure it's unique enough, no two can be the same!
    // To avoid confusion, make this the same as the name of the file. Mo' Bends will look for the animation data
    // file using this very key.
    "key": "mariojump",
    // This is the name that the user is going to see.
    "displayName": "Mario Jump!",
    // This should be your name, of course. (Unless you want me to take the credit <3)
    "author": "GoblinBob",
    // A proper description of what the pack adds/changes.
    "description": "This pack makes the player jump like Mario in Mario 64!",
    // An optional URL to a site where the animation data can be downloaded
    "downloadUrl": null
}

Animation file

Moving on, we can now describe the changes we want to the pack to make. The file that we're going to be making must have a '.bends' extension in the end, but while we're working on it it may be better to make it .json. My file is going to be called mariojump.bends. Make sure to call it the same as the key property in the meta file!

It's format is a little more complicated, but let's go step by step:

{
    "targets": {
        // This is the entity that we want to animate.
        "mobends-player": {
            // This is the state node that the system is going to start on. (Counting from 0)
            "entryNode": 0,
            "nodes": [
                // Here are state nodes describing the behaviour we want.
            ]
        }
    },
    "keyframeAnimations": {
        // Here should be animations that we are going to reference in the state nodes.
    }
}

Let's clear some things up.

State Nodes

A state node describes a state the entity can be in. We can decide whether we want the entity to be in a specific state or not, or when to change the state. In my example, I want the player to either play my jumping animation or not. For this I'm going to need two states: Not Jumping and Jumping.

Let's change our file to this:

{
    "targets": {
        "mobends-player": {
            "entryNode": 0,
            "nodes": [
                // We add two nodes, one for each state
                {
                    // (Node 0)
                    // With connections we can decide when we want to change the state.
                    "connections": [
                        {
                            // Let's describe a connection between this one node 1
                            "targetNodeIndex": 1,
                            // A change to node 1 will happen once this condition is fulfilled.
                            // In this case, it's once the state of the player is AIRBORNE, so we're
                            // not on ground anymore.
                            "triggerCondition": {
                                "type": "core:state",
                                "state": "AIRBORNE"
                            }
                        }
                    ]
                },
                {
                    // (Node 1)
                    "connections": [
                        // We change back to node 0 once the player is on ground again.
                        {
                            "targetNodeIndex": 0,
                            "triggerCondition": {
                                "type": "core:state",
                                "state": "ON_GROUND"
                            }
                        }
                    ],
                    // We can additionally perform animations when the player is at this state.
                    "layers": [
                        {
                            "type": "KEYFRAME",
                            "animationKey": "jump",
                            "playbackSpeed": 3.5
                        }
                    ]
                }
            ]
        }
    },
    "keyframeAnimations": {
    }
}