Hi guys
The script indicates that the animation should happen when the player is close to the item (trap floor),
however the animation only occurs when the player is away from the item.
It's something I can not explain, the script is executed, the sound is heard, the prompt appears, but the animation is not executed until the player away from the item, (>100).
function trap_floor_init(e)
end
function trap_floor_main(e)
SetAnimation(0)
--PlayerDist = GetPlayerDistance(e)
if GetPlayerFlatDistance(e) <= 100 and GetAnimationFrame(e) == 0 then
--SetAnimation(0)
PlayAnimation(e)
PlaySound(e,0)
Prompt("Frame = " ..GetAnimationFrame(e) .." plrDist = " ..round(GetPlayerFlatDistance(e),1))
end
end --main
function GetPlayerFlatDistance(e)
tPlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
tPlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
return math.sqrt(math.abs(tPlayerDX^2)+math.abs(tPlayerDZ^2))
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
Note: I've tried all the commented lines, and it does not make the difference.
Using "GetAnimationFrame(e) == 0", because the idea is start hurting player, when frame count reaches >=58.
I've all the complete script, anyway I decide to short it, just for isolate the issue.
any ideas?
Thanks in advance.
3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics