Jump to content

Recommended Posts

One way to do this would be adding the following into the 'fn' function for your character:

That seems to be something simillar to components.

    inst.entity:AddLight()
    inst.Light:SetFalloff(1)
    inst.Light:SetRadius(1)
    inst.Light:SetColour(180/255, 195/255, 150/255)
    inst.Light:SetIntensity(0)
    inst.Light:Enable(false)
    inst.Light:EnableClientModulation(true) -- probably something to reduce network

 

Another way that is found within heatrock prefab:
 

inst.Light = SpawnPrefab("myplayerlight") -- this one is inserted into your character prefab's fn.
...

local function lightfn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddLight()
    inst.entity:AddNetwork()

    inst:AddTag("FX") -- that tag is probably causing the prefab to act as a visual modifier, aka always docking on the parent prefab, and being transparent, unclickable

    inst.Light:SetRadius(.6)
    inst.Light:SetFalloff(1)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(235 / 255, 165 / 255, 12 / 255)
    inst.Light:Enable(false)

    inst.entity:SetPristine() -- that stuff tells the game that the entire code above should be ran on both client and the server, thus no networking isrequired

    if not TheWorld.ismastersim then
        return inst
    end

    inst.persists = false -- tells the game not to save these prefabs

    return inst
end

return Prefab("myplayerlight", lightfn)

myplayerlight along with lightfn may be renamed the way you like it and either added as a separate prefab. Or addd in your character prefab, to do the latter, you need to return both prefabs at the end, like

return Prefab("myplayerprefab", fn), Prefab("myplayerlight", lightfn)

 

Edited by IvanX

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...