Animations
Reload animations are inside "phasedReloads". Here, you can add as many reload animations as you want, and you can make them play in multiple conditions.
There’s phase, condition, duration, and animation.
"phase"is"RELOADING"and you don’t need to touch it."condition"is the condition the animation plays in.
Examples:
"condition": "reloadIterationIndex > 1"means the reload animation will play if the gun has more than one ammo."condition": "reloadIterationIndex == 1"means the reload animation will play if the gun has exactly one ammo."condition": "reloadIterationIndex == 0"means the animation will play if the gun has zero ammo.
After the "condition" is "duration", which is always set in milliseconds. Make sure it matches the millisecond duration of the animation in Blockbench.
After "duration" is "animation". This is the name of the animation you designed in Blockbench. A gun can have multiple reload animations, so you can write down the name of one of them here.
phasedReloads example:
"phasedReloads": [
{
"phase": "RELOADING",
"condition": "reloadIterationIndex > 1",
"duration": 1830,
"animation": "animation.model.reload"
},
{
"phase": "RELOADING",
"duration": 1830,
"condition": "reloadIterationIndex == 1",
"animation": "animation.model.reloadoneleft"
},
{
"phase": "RELOADING",
"condition": "reloadIterationIndex == 0",
"duration": 2470,
"animation": "animation.model.reloadempty"
}
]Each animation is contained by brackets {}.
- The first animation here allows the
reloadanimation to play if the gun has greater than one ammo. - The second animation allows the
reloadoneleftanimation to play if the gun has one ammo. - The third animation allows the
reloademptyanimation to play if the gun has zero ammo.
Of course, you can change these values and also add more animations. For example:
"condition": "reloadIterationIndex > 4""condition": "reloadIterationIndex == 2""condition": "reloadIterationIndex == 3"
This example is for guns like assault rifles, snipers, and pistols, not iterative reload weapons like shotguns. The code is similar, but shotgun reloading will be handled on the Shotgun Reloading page.
One use case for animations: if you want to have just one reload animation for your gun, you can have just one animation inside "phasedReloads" remove "condition". It might look something like this:
"phasedReloads": [
{
"phase": "RELOADING",
"duration": 1830,
"animation": "animation.model.reload"
}
]Note: You still need to specify the reload animation. Also, when creating or deleting animations in the code, be mindful of the , after the }.
Other animations like inspect, idle, and draw function very similarly.
Inspect animations go inside 'inspectAnimations'
"inspectAnimations": [
{
"name": "animation.model.inspect",
"duration": 6980,
"condition": "ammoCount > 1"
},
{
"name": "animation.model.inspectempty",
"duration": 6880,
"condition": "ammoCount == 0"
},
{
"name": "animation.model.inspectoneleft",
"duration": 6980,
"condition": "ammoCount == 1"
}
]First inspect animation here controls the inspect animation with a duration of 6980, and with a condition of "ammoCount > 1".
The ammoCount condition here is different from the conditions used in reload animations, and they are not interchangeable.
Second inspect animation controls the inspectempty animation set with a duration of 6880, and with a condition of "ammoCount == 0".
Third inspect animation is inspectoneleft with 6980 and ammoCount == 1.
Idle animations go inside 'idleAnimations'
"idleAnimations": [
{
"name": "animation.model.idle",
"duration": 100,
"condition": "ammoCount > 0"
},
{
"name": "animation.model.idleempty",
"duration": 100,
"condition": "ammoCount == 0"
}
]Same stuff as the inspect animations. Idle animations control how the gun animates when it’s idle, not doing anything like firing or reloading or drawing.
Draw animations go inside 'drawAnimations'
"drawAnimations": [
{
"name": "animation.model.draw",
"duration": 720,
"condition": "ammoCount > 0"
},
{
"name": "animation.model.drawempty",
"duration": 720,
"condition": "ammoCount == 0"
}
]Again, same deal as idle and inspect. Draw animations control the animation of the gun when the player pulls it out.
There are also fire animations. By default, the gun will play whatever fire animation you designed in Blockbench. However sometimes, you might want multiple fire animations for variety. In that case, you need to code them in, and assign them the “random” condition.
Example:
"fireAnimations": [
{
"name": "animation.model.fire",
"condition": "random"
},
{
"name": "animation.model.fire2",
"condition": "random"
}
]Every shot, the gun will play either ‘fire’ or ‘fire2’ at random.
If you really want to, you can also assign specific conditions like:
"fireAnimations": [
{
"name": "animation.model.fire",
"condition": "ammoCount > 1"
},
{
"name": "animation.model.fire2",
"condition": "ammoCount == 1"
}
]Here, the gun will play ‘fire’ for every shot when the ammo count is greater than 1. If the ammo count is 1, it will play ‘fire2’. Useful for a weapon like the M1 Garand where you want a special sound effect to play on the last shot, and the sound effect plays in the animation.