Titou
Member
So what I want to do is making a code that makes objects transparent when they are too far from the player.
I have this as a base but it doesn't work, I have attempted various ways, but none of them work...
and what I get (as my best result?):
I'm pretty much missing the logic, I'm not sure if my base is correct or not (I did tested with MF2_DONTDRAW before and it works apparently), so if someone could help me understand this, that would be nice! I pretty much want to get better at coding for other projects.
I have this as a base but it doesn't work, I have attempted various ways, but none of them work...
Lua:
addHook("MobjThinker", function(mobj)
local dist = R_PointToDist2(players[0].mo.x, players[0].mo.y, mobj.x, mobj.y)/FRACUNIT
if dist < 2000 and mobj.frame == FF_TRANS70
mobj.frame = $ - FF_TRANS70
elseif dist >= 2000 and mobj.frame != FF_TRANS70
mobj.frame = FF_TRANS70|$
end
end)
and what I get (as my best result?):
I'm pretty much missing the logic, I'm not sure if my base is correct or not (I did tested with MF2_DONTDRAW before and it works apparently), so if someone could help me understand this, that would be nice! I pretty much want to get better at coding for other projects.