简体   繁体   中英

env_lightglow not working when spawned via code

I'm creating a SENT that has a blinking glowing light inside. It mustnt' illuminate the environment, it should be like the light on top of combine mines. The problem is, I cannot get it to work. I've tried setting as many keyvalues as possible, including spawnflags, and I also gave it a name, but the light just isn't visible. It IS spawned, because IsValid() return true, but it has no visible effect in the game world.

Here's the code:

function ENT:Initialize()

self:SetModel( "models/Items/combine_rifle_ammo01.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:PhysWake()
self:SetIsActive( false )

-- Initialize the light object
local light = ents.Create( "env_lightglow" )
light:SetPos( self:GetPos() + Vector( 0, 0, 35 ) )
light:SetAngles( Angle( 0, 0, 0 ) )
light:SetParent( self )
light:SetName( "MotionSensorLight" )
light:SetKeyValue( "spawnflags", "0" )
light:SetKeyValue( "rendercolor", "255 255 255 255" )
light:SetKeyValue( "HorizontalGlowSize", "250" )
light:SetKeyValue( "VerticalGlowSize", "250" )
light:SetKeyValue( "MinDist", "800" )
light:SetKeyValue( "MaxDist", "600" )
light:Spawn()
self.LightEntity = light

end

The only light entity I've managed to get working using this method is env_projectedtexture, and either light_spot or point_spotlight, can't remember.

Nevermind, just booted up the game again this morning in a different map and it works now. I don't know if I needed to launch the game again or just use a map different from gm_construct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM