Seems I'm either very unlucky, or missing something.
Using ply:SetColor( r, g, b, a ) will set the player's colour, but not the alpha.
I'd like to know the method for setting a player's alpha [b]clientside[/b].
If anyone could point out what I'm doing wrong, or if there's another method entirely, would be very helpful.
If you don't wanna play with that stuff you can use render.SetBlend(0 - 1) in GAMEMODE:PrePlayerDraw(pl) and then render.SetBlend(1) in GAMEMODE:PostPlayerDraw(pl)
[lua]
function GM:PrePlayerDraw(pl)
render.SetBlend(0.5)
end
function GM:PostPlayerDraw(pl)
render.SetBlend(1)
end
[/lua]
That example would make every player have half visibility. Client-side of course. Especially useful if you want to change their alpha every frame.
I'd consider it generally easier and more efficient to set the color instead.
I've run into an issue where setting the RenderMode of a SENT clientside in the [B]Draw[/B] hook does not work to adjust the alpha. What hook would I use to set different transparency values for individual entities?
Here is some sample code that does no longer work (used to in GM12):
[lua]
function ENT:Draw()
local c = Color(255,0,0,50)
self:SetColor(c)
self:SetRenderMode(RENDERMODE_TRANSALPHA) -- added for GM13, tried RENDERMODE_TRANSCOLOR as well
self:DrawModel()
end
[/lua]
Same as I said above. Setting render.Blend
[QUOTE=Wizard of Ass;38524991]I'd consider it generally easier and more efficient to set the color instead.[/QUOTE]
you're right. It's more efficient to make and/or pass a color table every frame than to set the render blend.
[QUOTE=JetBoom;38526688]Same as I said above. Setting render.Blend
you're right. It's more efficient to make and/or pass a color table every frame than to set the render blend.[/QUOTE]
I am talking about setting the color once, not every frame.
what's all this rendermode shit all i ever did was
[lua]
local color = player:GetColor();
player:SetColor( color.r, color.g, color.b, 100 );
[/lua]
no per-frame bullshit or blending or anything i don't see what's complicated about this
[QUOTE=LauScript;38527993]what's all this rendermode shit all i ever did was
[lua]
local color = player:GetColor();
player:SetColor( color.r, color.g, color.b, 100 );
[/lua]
no per-frame bullshit or blending or anything i don't see what's complicated about this[/QUOTE]
Have you actually tried using that recently clientside?
[QUOTE=LauScript;38527993]what's all this rendermode shit all i ever did was
local color = player:GetColor(); player:SetColor( color.r, color.g, color.b, 100 );
no per-frame bullshit or blending or anything i don't see what's complicated about this[/QUOTE]
Are you trying to code for gmod12 or for gmod13? Because it looks like you DON'T have an idea whatsoever.
[QUOTE=ptown2;38530231]Are you trying to code for gmod12 or for gmod13? Because it looks like you DON'T have an idea whatsoever.[/QUOTE]
It would appear he just wanted to be a smartarse.
Thanks everyone else for some useful information.
[QUOTE=_nonSENSE;38524634][lua]
pl:SetColor(Color(255,255,255,50))
pl:SetRenderMode(RENDERMODE_TRANSALPHA)
[/lua][/QUOTE]
This doesn't appear to work for me.
Sorry, you need to Log In to post a reply to this thread.