diff --git a/.vscode/settings.json b/.vscode/settings.json index f885387f..73bca1ce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -165,6 +165,7 @@ "texpool", "textlist", "timeofday", + "tock", "tonemap", "toolrepair", "torchlike", diff --git a/source/player_model/init.ts b/source/player_model/init.ts index 022126a3..df23015a 100644 --- a/source/player_model/init.ts +++ b/source/player_model/init.ts @@ -100,6 +100,51 @@ namespace playerModel { // // speed based animation + // This works with the default character.b3d + const start = vector.create3d(math.pi / 4, 0, 0); + const end = vector.create3d(-math.pi / 4, 0, 0); + let timer = 0; + let state = false; + + minetest.register_globalstep((delta: number) => { + + timer += delta; + if (timer > 1) { + // Get the players. + let playerIterator: ObjectRef[] = minetest.get_connected_players(); + // Restart the timer. + timer = 0; + // Flip the state. + state = !state; + // Change the head bone override. + if (state) { + print("tick"); + for (let player of playerIterator) { + player.set_bone_override("Head", { + rotation: { + vec: start, + // Literally does nothing. + interpolation: 1.0, + absolute: false, + } + }); + } + } else { + print("tock"); + for (let player of playerIterator) { + player.set_bone_override("Head", { + rotation: { + vec: end, + // Literally does nothing. + interpolation: 1.0, + absolute: false, + } + }); + } + } + } + }); + // minetest.register_globalstep((_: number) => { // for (const player of minetest.get_connected_players()) { // let vel = player.get_velocity();