simplify yaw clamping
This commit is contained in:
parent
4bdd8eaa5f
commit
6cce24f04e
18
api.lua
18
api.lua
@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230423",
|
version = "20230425",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -383,17 +383,11 @@ function mob_class:set_yaw(yaw, delay)
|
|||||||
|
|
||||||
delay = mob_smooth_rotate and (delay or 0) or 0
|
delay = mob_smooth_rotate and (delay or 0) or 0
|
||||||
|
|
||||||
-- clamp yaw to a 360 range
|
-- simplified yaw clamp
|
||||||
if deg(self.object:get_yaw()) > 360 then
|
if yaw > 6.283185 then
|
||||||
self.object:set_yaw(rad(0))
|
yaw = yaw - 6.283185
|
||||||
elseif deg(self.object:get_yaw()) < 0 then
|
elseif yaw < 0 then
|
||||||
self.object:set_yaw(rad(360))
|
yaw = 6.283185 + yaw
|
||||||
end
|
|
||||||
|
|
||||||
if deg(yaw) > 360 then
|
|
||||||
yaw = yaw % 360
|
|
||||||
elseif deg(yaw) < 0 then
|
|
||||||
yaw = ((360 * 5) - yaw) % 360
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if delay == 0 then
|
if delay == 0 then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user