Resource Packs & Mods
Introduction
Resource Packs and Mods are used to replace or change the default components of Krunker such as textures, sounds, models and the interface. If you are making a game entirely from scratch, only the Custom CSS section is relevant.
You can load/unload modpacks using KrunkScript (client-side):
# load modpack by url
GAME.MODS.load(
url # str mod URL
);
# reset/unload mods
GAME.MODS.reset();
Mod Structure
The mod.zip has the following structure:
| Directory | Purpose | Format |
|---|---|---|
| textures/ | Replace default Krunker textures and images | .png only |
| models/ | Replace default Krunker models | .obj, .gltf |
| sound/ | Replace default sound assets | .mp3 only |
| scripts/ | Settings overrides and scripts | .txt |
| css/ | Override default CSS and fonts | .css |
| css-img/ | Images loaded via CSS | .png |
| shaders/ | Custom post-processing shaders | .glsl |
Custom CSS
Custom CSS can be used to fully customize the look and feel of menus and the interface.
/* override an image */
.iconProfile {
background-image: CSSIMAGE:profile; /* css-img/profile.png */
}
/* update game font */
@font-face {
font-family: 'GameFont';
src: CSSFONT:font2; /* css/fonts/font2.ttf */
}
Settings Override
Allows you to temporarily override user settings to accommodate specific game requirements like FOV, disabling skins, or saturation.
In your settings.txt file:
# settingname,value
shaderRendering,false
resolution,0.6
shadows,true
softShad,false
highResShad,false
postProcessing,true
bloom,false
These settings are reset once a player leaves your game.
Alternatively, use KrunkScript to set settings (client-side):
# update setting
GAME.SETTINGS.set(
key, # str setting key
val # str value of setting
);
# example
GAME.SETTINGS.set("resolution", "0.6");
Custom Assets
3D Models
Upload custom 3D models (supported: .obj, .gltf). Load into your scene using KrunkScript (client-side):
obj model = GAME.SCENE.addAsset(
aid, # str asset ID
x, # num x position
y, # num y position
z, # num z position
scl, # num scale
colr, # str color (optional)
data # obj additional data (optional)
);
Textures
Update an object's texture (client-side):
obj cube = GAME.SCENE.addCube("", "#fff", 0, 0, 0, 10, 10, 10);
cube.texture = "assetID"; # new asset id
Animations
To use animations on models, use the .gltf format. The asset must have animation clips attached:
# create an object
obj object = GAME.SCENE.addAsset("11441g", 0, 0, 0, 1);
# play animation on object
object.playAnim(
"Jump", # str clip name
1 # num repetitions (0 = infinite loop)
);
# stop animations on object
object.stopAnim();
# also works on player & AI objects
player.playAnim("Jump");
aiBot.playAnim("Jump");
Default player animations that play automatically if the custom model has these clips:
| Clip Name | When it Plays |
|---|---|
| Idle | While player is idle |
| Move | While player is moving |
| Crouch | While player is crouched |
| Jump | When player jumps |
| Melee | When player melees |
| Shoot | When player shoots |
Sounds
Play sounds using KrunkScript (client-side, .mp3 only):
# play sound in 2D space
obj sound = GAME.SOUND.play2D(
id, # num sound id
vol, # num volume (0-1)
rate, # num playback rate (0-1)
loop # bool loop
);
# play sound in 3D space
obj sound = GAME.SOUND.play3D(
id, # num sound id
vol, # num volume
x, # num x position
y, # num y position
z, # num z position
rate, # num playback rate
loop # bool loop
);
# control playback
sound.rate = 0.5;
sound.volume = 0.2;
sound.mute();
sound.unmute();
sound.play();
sound.stop();
sound.pause();
# fade volume
sound.fade(
0.1, # from volume
1.0, # to volume
500 # duration ms
);