Garry's Mod Wiki

ProjectedTexture

  ProjectedTexture ProjectedTexture()

Description

Creates a new ProjectedTexture.

Returns

1 ProjectedTexture
Newly created projected texture.

Example

Creates a simple ProjectedTexture attached to a Scripted Entity.

Note that this code must be ran on clientside only, not shared.

function ENT:Initialize() local lamp = ProjectedTexture() -- Create a projected texture self.lamp = lamp -- Assign it to the entity table so it may be accessed later -- Set it all up lamp:SetTexture( "effects/flashlight001" ) lamp:SetFarZ( 500 ) -- How far the light should shine lamp:SetPos( self:GetPos() ) -- Initial position and angles lamp:SetAngles( self:GetAngles() ) lamp:Update() end function ENT:OnRemove() if ( IsValid( self.lamp ) ) then self.lamp:Remove() end end function ENT:Think() -- Keep updating the light so it's attached to our entity -- you might want to call other functions here, you can do animations here as well if ( IsValid( self.lamp ) ) then self.lamp:SetPos( self:GetPos() ) self.lamp:SetAngles( self:GetAngles() ) self.lamp:Update() end end