Triggering Attachable Animations from Scripts (and Better)
First step: Create variables in the attachable
We need to create 3 variables:
A BP variable (the one we'll send from the resource pack)
A temporary variable
A variable for the resource pack (for animations, animation controllers, or render controllers, whatever)
First: Create the variables in the pre_setup.
Here we will assign the temporary variables and those of the "bp"
Example:
// t.bp_animation = is the temp variable bp_**
// v.bp_animation = is the bp variable bp_**
"parent_setup": "t.bp_animation = v.bp_animation ?? 0.0;", // We put "?? 0" so that Minecraft doesn't throw an error in the log
Another example:
// To assign multiple variables, do it this way; you can change 0.0 to another value to assign the default value.
"parent_setup": "t.bp_animation_1 = v.bp_animation_1 ?? 0.0; t.bp_animation_2 = v.bp_animation_2 ?? 0.0; t.bp_animation_3 = v.bp_animation_3 ?? 0.0;",
Second: Create the variables in the initialize:
Here we only need to create the RP variables
"initialize": [
"v.rp_animation_1 = 0.0;", // rp_**
"v.rp_animation_2 = 1.0;",
"v.rp_animation_3 = 2.0;"
],
Third: Transfer the values of the BP variables to the RP variables (using the temporary variables)
This is where the magic happens, and now the RP variables are useful and usable.
Example:
"pre_animation": [
"v.rp_animation_1 = t.bp_animation_1 ?? 0.0; v.rp_animation_2 = t.bp_animation_2 ?? 0.0; v.rp_animation_3 = t.bp_animation_3 ?? 0.0;"
],
