1
0
mirror of https://github.com/LoneWolfHT/headanim.git synced 2025-07-17 15:50:47 +02:00

7 Commits

Author SHA1 Message Date
7d4fb05ecb Add player_api as a dependency 2024-03-27 12:03:43 -07:00
fce30158a7 Update mod.conf 2021-08-12 08:04:18 -07:00
63fb160951 Update LICENSE 2021-08-12 08:01:19 -07:00
0e79459f96 Improve performance 2021-08-12 07:58:04 -07:00
daac6ff677 Add CDB link 2021-01-16 22:22:33 -08:00
6828735c14 Put a little 'spin' on the similar mod link 2021-01-16 22:14:27 -08:00
b3831e32e7 Update README.md 2021-01-16 22:09:00 -08:00
4 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 LoneWolfHT
Copyright (c) 2020-2021 LoneWolfHT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,2 +1,7 @@
# Headanim
[![ContentDB](https://content.minetest.net/packages/Lone_Wolf/headanim/shields/downloads/)](https://content.minetest.net/packages/Lone_Wolf/headanim/)
Makes player heads follow their look dir in Minetest. Requires version 5.3+
## Similar mods
* https://github.com/minetest-mods/playeranim: A lot more complex (and possibly slower?) than Headanim but looks nicer as a result

View File

@ -1,5 +1,21 @@
local get_connected_players = minetest.get_connected_players
local abs = math.abs
local deg = math.deg
local basepos = vector.new(0, 6.35, 0)
local lastdir = {}
minetest.register_globalstep(function(dtime)
for _, player in pairs(minetest.get_connected_players()) do
player:set_bone_position("Head", vector.new(0, 6.35, 0), vector.new(-math.deg(player:get_look_vertical()), 0, 0))
for _, player in pairs(get_connected_players()) do
local pname = player:get_player_name()
local ldeg = -deg(player:get_look_vertical())
if abs((lastdir[pname] or 0) - ldeg) > 4 then
lastdir[pname] = ldeg
player:set_bone_position("Head", basepos, {x = ldeg, y = 0, z = 0})
end
end
end)
minetest.register_on_leaveplayer(function(player)
lastdir[player:get_player_name()] = nil
end)

View File

@ -1 +1,3 @@
name = headanim
depends = player_api
min_minetest_version = 5.3