2nd attempt at clamping yaw to stop spinny mobs

This commit is contained in:
tenplus1 2023-04-23 16:34:35 +01:00
parent 36a26d2d21
commit 4bdd8eaa5f
1 changed files with 14 additions and 1 deletions

15
api.lua
View File

@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20230403",
version = "20230423",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -383,6 +383,19 @@ function mob_class:set_yaw(yaw, delay)
delay = mob_smooth_rotate and (delay or 0) or 0
-- clamp yaw to a 360 range
if deg(self.object:get_yaw()) > 360 then
self.object:set_yaw(rad(0))
elseif deg(self.object:get_yaw()) < 0 then
self.object:set_yaw(rad(360))
end
if deg(yaw) > 360 then
yaw = yaw % 360
elseif deg(yaw) < 0 then
yaw = ((360 * 5) - yaw) % 360
end
if delay == 0 then
self.object:set_yaw(yaw)