0

In some but not all entity animation files, there are references to variables which are not regular Molang queries. Sometimes, these variables are defined in the client entity .json file, like the tcos0 variable for the piglin:

Variable definition in client entity .json file:

"pre_animation": [
    "variable.tcos0 = (Math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;",

    ... // Other variable declarations: not relevant here
],

Variable use in animation .json file:

"animation.piglin.move" : {
    "loop" : true,
    "bones": {
        "leftear": {
            "rotation" : [ 0.0, 0.0, "variable.tcos0 * 0.5" ]
        },
        "rightear": {
            "rotation" : [ 0.0, 0.0, "-variable.tcos0 * 0.5" ]
        },
        "leftarm" : {
            "rotation" : [ "variable.tcos0", 0.0, 0.0 ]
        },
        "leftleg" : {
            "rotation" : [ "-variable.tcos0 * 1.4", 0.0, 0.0 ]
        },
        "rightarm" : {
            "rotation" : [ "-variable.tcos0", 0.0, 0.0 ]
        },
        "rightleg" : {
            "rotation" : [ "variable.tcos0 * 1.4", 0.0, 0.0 ]
        }
    }
},

Often, however, I've come across entities where the animations reference variables that don't seem to be defined anywhere.

Most recently, when trying to make a custom chicken, I couldn't find the definition for variable.wing_flap in any of the chicken-related .json files in the vanilla samples pack. When I tried spawning one of my custom chicken entities using its spawn egg, I got an error message saying that the variable wasn't defined, and the wing-flapping animation wouldn't play (all other animations for the same entity were working fine).

I tried providing my own definition of the variable in the custom chicken's client entity file, but wasn't sure what input to use to get the same effect as for the vanilla entity animation.

Are these "missing" variables accessible anywhere, or are they hardcoded values that aren't part of the default resource pack?

1
  • For a custom chicken entity, it's possible to recreate the wing animation by ignoring the wing_flap variable and instead using the following inside custom_chicken.animation.json: "animation.custom_chicken.general": { "loop": true, "bones": { "wing0": { "rotation": [0, 0, "(1 - query.is_on_ground) * Math.cos(10*query.vertical_speed) * Math.cos(10*query.vertical_speed) * 90"]}, "wing1": { "rotation": [0, 0, "-(1 - query.is_on_ground) * Math.cos(10*query.vertical_speed) * Math.cos(10*query.vertical_speed) * 90"] } } } Commented Jun 30 at 21:49

0

You must log in to answer this question.

Browse other questions tagged .