This document describes how to set up a light Actor that changes color and slowly fades away on contact.
This will be done using a Point Light Component containing a Box Component to serve as an overlap trigger and a Timeline component to manipulate the Point Light Actor.

Creating the Fading Light Actor
-
Create the new Blueprint project based on Blank template, name it FadingLights.
Click for full view.
-
Navigate to the Content Browser, click the Add (+) button to create a new Blueprint Actor class named BP_LightActor.
-
Double-click the BP_LightActor from the Content Browser to open it in the Blueprint Editor and open the Class Defaults.
Click for full view.
-
Navigate to the Component tab and click Add(+) button, select Box Collision from the dropdown menu, and rename it to OverlapCollision.
-
Navigate to the Components tab, select and drag the OverlapCollision onto the DefaultSceneRoot to make OverlapCollision the new Root Component.
-
Click Add(+) in the Component tab, search for and select Point Light.
-
Open the Event Graph, right-click the Graph, search for and select Add Timeline from the Blueprint Context Menu. Name the Timeline PointLightTimeline.
-
Navigate to the My Blueprint tab and from the Variables category click the (+) button for adding a new variable of type float. Name the variable BrightnessMultiplier and compile blueprint. Set its Default Value to 20.0 in the Detail panel.
-
Click Compile and Save buttons.
Setting Up the Brightness Track
When the player overlaps with the light Actor's box component bounds, the Timeline component will require a float curve to manipulate the brightness value of the Point Light component.
The luminosity will have an initial value of 5000 and will decrease to 0 over the span of 5 seconds.
-
Double-click the PointLightTimeline node to open the Timeline Editor, click Track > Add Float Track.
Click for full view.
-
Name the float curve track LightBrightnessFloatTrack, press Shift and click on the Graph for adding two keys to the track. Click on the first key and set its time-value to (0, 5000), click the second key and set its time-value to (5, 0).
Click for full view.
-
The completed LightBrightnessFloat track will appear as it does below.
Click for full view.
Setting Up The Color Track
When the player overlaps with the light Actor's box component bounds, the PointLight Timeline will require a linear color curve track to manipulate the point light component's color property.
-
From the Timeline Editor add a color curve track.
Click for full view.
-
Name the new color track LightLinearColorTrack.
Click for full view.
-
Double-click the first color key to modify it with a time of 0, and RGB value of: (R:1,G:0.665,B:0.015).
Click for full view.
-
Double-click the second color key to modify it with a time of 5, and RGB value of: (R: 0, G: 0, B: 0).
Click for full view.
-
Click Compile and Save buttons.
-
Your completed color track will appear as it does below.
Click for full view.
Work-In-Progress Blueprint
Click for full view.
Creating the Collision Overlap Event and Update Logic
The Box Component requires the ability to trigger the TimelineComponent when an Actor enters its collision bounds.
Additionally, the PointLightTimeline will require update logic in order to change its luminosity and color.
-
Navigate to the Components tab in the Blueprint Editor and select the OverlapCollision box component. From the Details panel, scroll down to the Events category and click the + icon next to the On Component Begin Overlap Event.
-
Drag off the On Component Begin Overlap (OverlapCollision) node's execution pin and connect it to the PointTimelineComponent node's Play pin.
Begin Object Class=/Script/BlueprintGraph.K2Node_Timeline Name="K2Node_Timeline_0" TimelineName="PointLightTimeline" TimelineGuid=9B6871DF41CC70785FBD70A935625EAC NodePosX=448 NodePosY=80 bCanRenameNode=True ErrorType=1 NodeGuid=CD70BA9E43E1F7EB1FF420816FF55084 CustomProperties Pin (PinId=E50CDF574B8B5BE1ECFB4AB4CE506DCD,PinName="Play",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_ComponentBoundEvent_0 3608BECC49E96377DB2960B5B1108C19,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=7B459F68414F7C0977CD2191A446853E,PinName="PlayFromStart",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=3B492C5145FAF24CAB2B7AAEEA07A923,PinName="Stop",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=BE2C31AB4E0D68E68EA684B10CB8BED5,PinName="Reverse",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=BD1E6E7E48EE7A9DBF6E6D82849920FF,PinName="ReverseFromEnd",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=B34A88804DC700EB96C1A08A8BC63B0E,PinName="Update",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_2 9C312EB049C5A1020D6797A147DEABB8,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=8D513CA546C97BEAC7B6A4AF44A12299,PinName="Finished",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=E6EE52734B58BA4623436EA5FE8BB8BC,PinName="SetNewTime",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=87A9CA2245DA3C1405FEE58EC3344746,PinName="NewTime",PinType.PinCategory="real",PinType.PinSubCategory="float",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=CA29340A4DA024A1403EF6BDDAF84042,PinName="Direction",Direction="EGPD_Output",PinType.PinCategory="byte",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Enum'"/Script/Engine.ETimelineDirection"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=5D3D277B4502D9621FEE289C0C2C69A1,PinName=" LightBrightnessFloatTrack",Direction="EGPD_Output",PinType.PinCategory="real",PinType.PinSubCategory="float",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_PromotableOperator_0 82EF0A4B4E496697FA249BB6F7507FDF,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=E21609824D5C866D9DB781A807FE09D0,PinName="LightLinearColorTrack",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.LinearColor"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Knot_6 D90419F74048C11128F75A94675B08E1,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) End Object Begin Object Class=/Script/BlueprintGraph.K2Node_ComponentBoundEvent Name="K2Node_ComponentBoundEvent_0" DelegatePropertyName="OnComponentBeginOverlap" DelegateOwnerClass=Class'"/Script/Engine.PrimitiveComponent"' ComponentPropertyName="OverlapCollision" DelegatePropertyDisplayName=NSLOCTEXT("UObjectDisplayNames", "PrimitiveComponent:OnComponentBeginOverlap", "On Component Begin Overlap") EventReference=(MemberParent=Package'"/Script/Engine"',MemberName="ComponentBeginOverlapSignature__DelegateSignature") bInternalEvent=True CustomFunctionName="BndEvt__BP_LightActor_OverlapCollision_K2Node_ComponentBoundEvent_0_ComponentBeginOverlapSignature__DelegateSignature" NodePosX=48 NodePosY=80 NodeGuid=BBCDCF4E488AC70C2C1425807166E35D CustomProperties Pin (PinId=1759D9404D426D8180DC08AED4CC47BD,PinName="OutputDelegate",Direction="EGPD_Output",PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent=BlueprintGeneratedClass'"/Game/Blueprints/BP_LightActor.BP_LightActor_C"',MemberName="BndEvt__BP_LightActor_OverlapCollision_K2Node_ComponentBoundEvent_0_ComponentBeginOverlapSignature__DelegateSignature"),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=3608BECC49E96377DB2960B5B1108C19,PinName="then",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Timeline_0 E50CDF574B8B5BE1ECFB4AB4CE506DCD,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=E89620D04B90AC9AE8C0E791F2FF1B39,PinName="OverlappedComponent",PinToolTip="Overlapped Component\nPrimitive Component Object Reference",Direction="EGPD_Output",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.PrimitiveComponent"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=1778E5CB43BF80FE3F648D940DF0C142,PinName="OtherActor",PinToolTip="Other Actor\nActor Object Reference",Direction="EGPD_Output",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.Actor"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=6F3818FC4E9B3EB37CB1A7BD037EBFB7,PinName="OtherComp",PinToolTip="Other Comp\nPrimitive Component Object Reference",Direction="EGPD_Output",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.PrimitiveComponent"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=4C32537F4195796C764B9AB4A1D531EE,PinName="OtherBodyIndex",PinToolTip="Other Body Index\nInteger",Direction="EGPD_Output",PinType.PinCategory="int",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0",AutogeneratedDefaultValue="0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=CCD65B384CBC4EFEC93021905B1DFAFF,PinName="bFromSweep",PinToolTip="From Sweep\nBoolean",Direction="EGPD_Output",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="false",AutogeneratedDefaultValue="false",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=69378B444803AF25C64D9F8D54850B9B,PinName="SweepResult",PinToolTip="Sweep Result\nHit Result Structure (by ref)",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/Engine.HitResult"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=True,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) End Object -
From the Components tab, drag the PointLight component into the Event Graph.
Begin Object Class=/Script/BlueprintGraph.K2Node_VariableGet Name="K2Node_VariableGet_0" VariableReference=(MemberName="PointLight",bSelfContext=True) NodePosX=848 NodePosY=144 NodeGuid=5EB41437410885083479FEB985CC498E CustomProperties Pin (PinId=BE0F44F644A651B59B7B768F23043181,PinName="PointLight",Direction="EGPD_Output",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.PointLightComponent"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_2 B0B1479D4AF0E3B08F76A09E55059CE2,K2Node_Knot_0 F1E8A86F4F35354E9427F38B9E297E03,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=EF8864E146E66B02527255B9E06B6025,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=BlueprintGeneratedClass'"/Game/Blueprints/BP_LightActor.BP_LightActor_C"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) End Object -
Drag off the PointLight's pin, search for and add Set Intensity node in the actions menu.
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_2" FunctionReference=(MemberParent=Class'"/Script/Engine.LightComponent"',MemberName="SetIntensity") NodePosX=1040 NodePosY=64 NodeGuid=23E0F4404C18096DF62804AFAA7BC709 CustomProperties Pin (PinId=9C312EB049C5A1020D6797A147DEABB8,PinName="execute",PinToolTip="\nExec",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Timeline_0 B34A88804DC700EB96C1A08A8BC63B0E,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=87A5CA2F43E3E67419AFD1A8953F299B,PinName="then",PinToolTip="\nExec",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_3 744D0148419A07627F1A9F978A0C575D,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=B0B1479D4AF0E3B08F76A09E55059CE2,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nLight Component Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.LightComponent"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_VariableGet_0 BE0F44F644A651B59B7B768F23043181,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=FDEA2486488BDE31C3E56B9DDFB9CD27,PinName="NewIntensity",PinToolTip="New Intensity\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",LinkedTo=(K2Node_PromotableOperator_0 69A2EF8C4A59A02C101F58AD8511E67A,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) End Object -
From the PointLightTimeline node, drag off the Light Brightness Float Track pin, search for and add Multiply node in the actions menu.
Begin Object Class=/Script/BlueprintGraph.K2Node_PromotableOperator Name="K2Node_PromotableOperator_0" bIsPureFunc=True FunctionReference=(MemberParent=Class'"/Script/Engine.KismetMathLibrary"',MemberName="Multiply_DoubleDouble") NodePosX=864 NodePosY=192 NodeGuid=64A7E68440746F350AC19F86346C4452 CustomProperties Pin (PinId=82EF0A4B4E496697FA249BB6F7507FDF,PinName="A",PinToolTip="A\nFloat (double-precision)",PinType.PinCategory="real",PinType.PinSubCategory="double",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Timeline_0 5D3D277B4502D9621FEE289C0C2C69A1,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=75D0A21342595E689923BA87FB4EF370,PinName="B",PinToolTip="B\nFloat (double-precision)",PinType.PinCategory="real",PinType.PinSubCategory="double",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_VariableGet_1 485EF0D44BC98AA6894EF282D5F53F5F,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=69A2EF8C4A59A02C101F58AD8511E67A,PinName="ReturnValue",PinToolTip="Return Value\nFloat (double-precision)\n\nMultiplication (A * B)",Direction="EGPD_Output",PinType.PinCategory="real",PinType.PinSubCategory="double",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_2 FDEA2486488BDE31C3E56B9DDFB9CD27,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) End Object -
From the My Blueprint tab drag the BrightnessMultiplier float variable into the Event Graph, select Get Brightness Multiplier, then connect it to the Multiply node.
Begin Object Class=/Script/BlueprintGraph.K2Node_VariableGet Name="K2Node_VariableGet_1" VariableReference=(MemberName="BrightnessMultiplier",MemberGuid=FCCF7F5E4A6E4FD75FAA849998FE2E92,bSelfContext=True) NodePosX=864 NodePosY=288 NodeGuid=3B08B13441FCF1AEDC7E3CA58137A9D2 CustomProperties Pin (PinId=485EF0D44BC98AA6894EF282D5F53F5F,PinName="BrightnessMultiplier",Direction="EGPD_Output",PinType.PinCategory="real",PinType.PinSubCategory="double",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",LinkedTo=(K2Node_PromotableOperator_0 75D0A21342595E689923BA87FB4EF370,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=8978695144D2F58451CFF4858B5A8790,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=BlueprintGeneratedClass'"/Game/Blueprints/BP_LightActor.BP_LightActor_C"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) End Object -
Connect the Update pin of the PointLightTimeline to the Set Intensity node, then connect the Return Value pin of the Multiply node to the New Intensity input pin of the Set Intensity node.
-
Drag off the PointLight node, search for and select Set Light Color from the actions menu.
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_3" FunctionReference=(MemberParent=Class'"/Script/Engine.LightComponent"',MemberName="SetLightColor") NodePosX=1296 NodePosY=64 NodeGuid=43D9BD7C4283FC673F36A1930C3243C6 CustomProperties Pin (PinId=744D0148419A07627F1A9F978A0C575D,PinName="execute",PinToolTip="\nExec",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_2 87A5CA2F43E3E67419AFD1A8953F299B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=D792D59441A56ECC8C3D4CB3900F9C66,PinName="then",PinToolTip="\nExec",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=FE00319941A34DE91479318F2093ECE0,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nLight Component Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.LightComponent"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Knot_1 808A85F1410FB25AEFC0C8B494E8DA53,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=BD932EBD48DCC38B6CA11F9AED634AB2,PinName="NewLightColor",PinToolTip="New Light Color\nLinear Color Structure",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.LinearColor"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Knot_3 912593C04753CE1C51DEF2B3D7CFA5AD,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) CustomProperties Pin (PinId=6602709A43E5CCC5AB675882406E458C,PinName="bSRGB",PinToolTip="SRGB\nBoolean",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="true",AutogeneratedDefaultValue="true",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) End Object -
Connect the Light Linear Color Track pin of the PointLightTimeline node to the New Light Color pin of the Set Light Color node. Then connect the execution pin from the Set Intensity node to the Set Light Color node.
-
Click Compile and Save buttons.

Finished Blueprint
Level Setup
To best demonstrate the functionality of the code you have written, you will need to remove all Light Sources Actors from the Level.
-
In the Content Browser navigate to the BP_LightActor Asset, select it and drag it into the Level.
Click for full view.
-
Select the BP_LightActor in the World Outliner, navigate to the Details panel and set the Location settings to (0, 0, 300) and the Scale settings to (10, 10, 10).
-
Delete the DirectionalLight Actor in the World Outliner.
-
Level should look as following.
Click for full view.
End Result
Now that the Light Actor and Level have been set up, click Play (PIE) to automatically take possession of the spectator Pawn.
You can control the spectator Pawn and navigate into the Light Actor's box component bounds.
Once the Timeline Component's Play function has been triggered, the light's color and luminosity should begin to change over a 5-second timespan.

This document describes how to set up a light Actor that changes color and slowly fades away on contact.
This will be done using a Point Light Component containing a Box Component to serve as an overlap trigger and a Timeline component to manipulate the Point Light Actor.

Creating the Fading Light Actor
-
Create the new C++ project based on Blank template, name it FadingLights.
Click for full view.
-
Navigate to the Content Browser, click C++ Classes folder, then click Add (+) button and select New C++ Class.
Click for full view.
-
Select Actor as a Parent Class.
Click for full view.
-
Name created Actor as LightActor.
Click for full view.
-
When new Actor is created, Visual Studio automatically opens
LightActor.h
andLightActor.cpp
files. Navigate to theLightActor.h
file and declare the following:LightActor.h
#include "Components/TimelineComponent.h"
-
Next, in the
LightActor
class definition, add the following code:LightActor.h
public: UPROPERTY(EditAnywhere) UCurveFloat* PointLightFloatCurve; UPROPERTY(EditAnywhere) UCurveLinearColor* PointLightColorCurve; protected: //TimelineComponent to animate the point light component. UPROPERTY(VisibleAnywhere, BlueprintReadWrite) UTimelineComponent* LightTimelineComp; //BoxComponent which will be used as our proximity overlap volume. UPROPERTY(EditAnywhere, BlueprintReadWrite) class UBoxComponent* LightOverlapVolume; UPROPERTY(EditAnywhere,BlueprintReadWrite) class UPointLightComponent* PointLightComp; //Track used for Pointlight brightness FOnTimelineFloat UpdateBrightnessTrack; //Track used for Pointlight color FOnTimelineLinearColor UpdateColorTrack; //Function to Update Light's brightness relative to UpdateBrightnessTrack UFUNCTION() void UpdateLightBrightness(float BrightnessOutput); //Function to Update Light's color relative to UpdateColorTrack UFUNCTION() void UpdateLightColor(FLinearColor ColorOutput); UPROPERTY(EditDefaultsOnly) float BrightnessMultiplier;
-
Navigate to
LightActor.cpp
and add the following class libraries.LightActor.cpp
#include "Components/BoxComponent.h" #include "Components/PointLightComponent.h"
-
In the constructor for
ALightActor::ALightActor
declare the following:LightActor.cpp
ALightActor::ALightActor() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; //Create our Default Components PointLightComp = CreateDefaultSubobject<UPointLightComponent>(TEXT("PointLightComp")); LightTimelineComp = CreateDefaultSubobject<UTimelineComponent>(TEXT("LightTimelineComp")); LightOverlapVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("LightOverlapVolume")); //Setup our Attachments RootComponent = LightOverlapVolume; PointLightComp->AttachToComponent(LightOverlapVolume, FAttachmentTransformRules::KeepRelativeTransform); //Initialize Brightness Multiplier BrightnessMultiplier = 20.0f; }
-
Next, implement the Point Light component's
UFunction
methods:LightActor.cpp
void ALightActor::UpdateLightBrightness(float BrightnessOutput) { PointLightComp->SetLightBrightness(BrightnessOutput * 20.0f); } void ALightActor::UpdateLightColor(FLinearColor ColorOutput) { PointLightComp->SetLightColor(ColorOutput); }
-
Then, in the
BeginPlay
method, add the following code:LightActor.cpp
void ALightActor::BeginPlay() { Super::BeginPlay(); //Binding our float and color track to their respective functions UpdateBrightnessTrack.BindDynamic(this, &ALightActor::UpdateLightBrightness); UpdateColorTrack.BindDynamic(this, &ALightActor::UpdateLightColor); //If we have a float curve, bind it's graph to our update function if (PointLightFloatCurve) { LightTimelineComp->AddInterpFloat(PointLightFloatCurve, UpdateBrightnessTrack); } //If we have a linear color curve, bind it's graph to our update function if (PointLightColorCurve) { LightTimelineComp->AddInterpLinearColor(PointLightColorCurve, UpdateColorTrack); } }
-
Compile your code.
-
From the Content Browser, navigate to the C++ Classes folder.
-
Right click the LightActor, select Create Blueprint Class based on LightActor, and name the Blueprint Actor BP_LightActor.
The BP_LightActor's Class Defaults will appear as they do below:
Click for full view.
Work-In-Progress Code
LightActor.h
//Copyright 1998-2022 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/TimelineComponent.h"
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "LightActor.generated.h"
UCLASS()
class FADINGLIGHTS_API ALightActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ALightActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
public:
UPROPERTY(EditAnywhere)
UCurveFloat* PointLightFloatCurve;
UPROPERTY(EditAnywhere)
UCurveLinearColor* PointLightColorCurve;
protected:
//TimelineComponent to animate the point light component.
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UTimelineComponent* LightTimelineComp;
//BoxComponent which will be used as our proximity overlap volume.
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UBoxComponent* LightOverlapVolume;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UPointLightComponent* PointLightComp;
//Track used for Pointlight brightness
FOnTimelineFloat UpdateBrightnessTrack;
//Track used for Pointlight color
FOnTimelineLinearColor UpdateColorTrack;
//Function to Update Light's brightness relative to UpdateBrightnessTrack
UFUNCTION()
void UpdateLightBrightness(float BrightnessOutput);
//Function to Update Light's color relative to UpdateColorTrack
UFUNCTION()
void UpdateLightColor(FLinearColor ColorOutput);
UPROPERTY(EditDefaultsOnly)
float BrightnessMultiplier;
};
LightActor.cpp
//Copyright 1998-2022 Epic Games, Inc. All Rights Reserved.
#include "LightActor.h"
#include "Components/BoxComponent.h"
#include "Components/PointLightComponent.h"
// Sets default values
ALightActor::ALightActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//Create our Default Components
PointLightComp = CreateDefaultSubobject<UPointLightComponent>(TEXT("PointLightComp"));
LightTimelineComp = CreateDefaultSubobject<UTimelineComponent>(TEXT("LightTimelineComp"));
LightOverlapVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("LightOverlapVolume"));
//Setup our Attachments
RootComponent = LightOverlapVolume;
PointLightComp->AttachToComponent(LightOverlapVolume, FAttachmentTransformRules::KeepRelativeTransform);
//Initialize Brightness Multiplier
BrightnessMultiplier = 20.0f;
}
// Called when the game starts or when spawned
void ALightActor::BeginPlay()
{
Super::BeginPlay();
//Binding our float and color track to their respective functions
UpdateBrightnessTrack.BindDynamic(this, &ALightActor::UpdateLightBrightness);
UpdateColorTrack.BindDynamic(this, &ALightActor::UpdateLightColor);
//If we have a float curve, bind it's graph to our update function
if (PointLightFloatCurve)
{
LightTimelineComp->AddInterpFloat(PointLightFloatCurve, UpdateBrightnessTrack);
}
//If we have a linear color curve, bind it's graph to our update function
if (PointLightColorCurve)
{
LightTimelineComp->AddInterpLinearColor(PointLightColorCurve, UpdateColorTrack);
}
}
// Called every frame
void ALightActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ALightActor::UpdateLightBrightness(float BrightnessOutput)
{
PointLightComp->SetLightBrightness(BrightnessOutput * 20.0f);
}
void ALightActor::UpdateLightColor(FLinearColor ColorOutput)
{
PointLightComp->SetLightColor(ColorOutput);
}
Creating and Binding the Collision Overlap Event
The Box Component requires the ability to trigger the TimelineComponent when an Actor enters its collision bounds.
-
Navigate to the class definition of the
LightActor.h
file and declare the following underBrightnessMultiplier
:LightActor.h
protected: UFUNCTION() void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
-
Next, navigate to the
LightActor.cpp
file and implement theOnOverlapBegin
function.LightActor.cpp
void ALightActor::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { LightTimelineComp->Play(); }
-
Bind the overlap function in the
BeginPlay
method:LightActor.cpp
//Binding our Box Component to our Light Actor's Overlap Function LightOverlapVolume->OnComponentBeginOverlap.AddDynamic(this, &ALightActor::OnOverlapBegin);
-
Compile your code.
Finished Code
LightActor.h
//Copyright 1998-2022 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/TimelineComponent.h"
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "LightActor.generated.h"
UCLASS()
class FADINGLIGHTS_API ALightActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ALightActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
public:
UPROPERTY(EditAnywhere)
UCurveFloat* PointLightFloatCurve;
UPROPERTY(EditAnywhere)
UCurveLinearColor* PointLightColorCurve;
protected:
//TimelineComponent to animate the point light component.
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UTimelineComponent* LightTimelineComp;
//BoxComponent which will be used as our proximity overlap volume.
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UBoxComponent* LightOverlapVolume;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
class UPointLightComponent* PointLightComp;
//Track used for Pointlight brightness
FOnTimelineFloat UpdateBrightnessTrack;
//Track used for Pointlight color
FOnTimelineLinearColor UpdateColorTrack;
//Function to Update Light's brightness relative to UpdateBrightnessTrack
UFUNCTION()
void UpdateLightBrightness(float BrightnessOutput);
//Function to Update Light's color relative to UpdateColorTrack
UFUNCTION()
void UpdateLightColor(FLinearColor ColorOutput);
UPROPERTY(EditDefaultsOnly)
float BrightnessMultiplier;
protected:
UFUNCTION()
void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
};
LightActor.cpp
//Copyright 1998-2022 Epic Games, Inc. All Rights Reserved.
// Fill out your copyright notice in the Description page of Project Settings.
#include "LightActor.h"
#include "Components/BoxComponent.h"
#include "Components/PointLightComponent.h"
// Sets default values
ALightActor::ALightActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
//Create our Default Components
PointLightComp = CreateDefaultSubobject<UPointLightComponent>(TEXT("PointLightComp"));
LightTimelineComp = CreateDefaultSubobject<UTimelineComponent>(TEXT("LightTimelineComp"));
LightOverlapVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("LightOverlapVolume"));
//Setup our Attachments
RootComponent = LightOverlapVolume;
PointLightComp->AttachToComponent(LightOverlapVolume, FAttachmentTransformRules::KeepRelativeTransform);
//Initialize Brightness Multiplier
BrightnessMultiplier = 20.0f;
}
// Called when the game starts or when spawned
void ALightActor::BeginPlay()
{
Super::BeginPlay();
//Binding our float and color track to their respective functions
UpdateBrightnessTrack.BindDynamic(this, &ALightActor::UpdateLightBrightness);
UpdateColorTrack.BindDynamic(this, &ALightActor::UpdateLightColor);
//If we have a float curve, bind it's graph to our update function
if (PointLightFloatCurve)
{
LightTimelineComp->AddInterpFloat(PointLightFloatCurve, UpdateBrightnessTrack);
}
//If we have a linear color curve, bind it's graph to our update function
if (PointLightColorCurve)
{
LightTimelineComp->AddInterpLinearColor(PointLightColorCurve, UpdateColorTrack);
}
//Binding our Box Component to our Light Actor's Overlap Function
LightOverlapVolume->OnComponentBeginOverlap.AddDynamic(this, &ALightActor::OnOverlapBegin);
}
// Called every frame
void ALightActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ALightActor::UpdateLightBrightness(float BrightnessOutput)
{
PointLightComp->SetLightBrightness(BrightnessOutput * 20.0f);
}
void ALightActor::UpdateLightColor(FLinearColor ColorOutput)
{
PointLightComp->SetLightColor(ColorOutput);
}
void ALightActor::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
LightTimelineComp->Play();
}
Setting Up the Brightness Track
When the player overlaps with the light Actor's box component bounds, the Timeline component will require a float curve to manipulate the Point Light component's brightness value.
The luminosity will have an initial value of 5000 and will decrease to 0 over the span of 5 seconds.
-
Navigate to the Content Browser, select Add (+) > Miscellaneous > Curve.
-
Select CurveFloat and name the Asset BrightnessCurveFloat.
-
Double-click the BrightnessCurveFloat to open the Timeline Editor.
-
Add two keys to the Float Curve, by right clicking on the Graph, then select Add Key. Adjust time-value of the first key to the (0, 5000). Adjust time-value of the second key to the (5, 0). Your BrightnessCurveFloat should look as following:
Click for full view.
-
Save the BrightnessCurveFloat, then navigate back to the Content Browser and double-click the BP_LightActor to open its Class Defaults.
-
Navigate to the Details panel and select Brightness Curve Float from the Point Light Float Curve dropdown menu.
-
Click Compile and Save buttons.
Setting Up the Color Track
When the player overlaps with the light Actor's box component bounds, the PointLight Timeline will require a linear color curve track to manipulate the Point Light component's color property.
-
Navigate to the Content Browser, select Add (+) > Miscellaneous > Curve.
-
Select CurveLinearColor and name the asset LinearColorCurve.
-
Double-click the LinearColorCurve to open the Timeline Editor.
-
Double-click the first color key to modify it, set RGB value of: (R:1, G:0.665, B:0.015).
Click for full view.
-
Double-click the second color key to modify it, set RGB value of: (R:0, G:0, B:0).
Click for full view.
-
Select second Point on the Graph by clicking on it and set the time to 5 seconds.
Click for full view.
-
Your LinearColorCurve should look as following:
Click for full view.
-
Save the LinearColorCurve, then navigate back to the Content Browser and double-click the BP_LightActor to open its class defaults.
-
Navigate to the Details Panel and select Brightness Curve Float from the Point Light Float Curve dropdown menu.
-
Click Compile and Save buttons.
Level Setup
To best demonstrate the functionality of the code you have written, you will need to remove all Light Sources Actors from the Level.
-
In the Content Browser navigate to the BP_LightActor Asset, select it and drag it into the Level.
Click for full view.
-
Select the BP_LightActor in the World Outliner, navigate to the Details panel and set the Location settings to (0, 0, 300) and the Scale settings to (10, 10, 10).
-
Delete the DirectionalLight Actor in the World Outliner.
-
The Level should look as the following.
Click for full view.
End Result
Now that the Light Actor and Level have been set up, click Play (PIE) to automatically take possession of the spectator Pawn.
You can control the spectator Pawn and navigate into the Light Actor's box component bounds.
Once the Timeline Component's Play function has been triggered, the light's color and luminosity should begin to change over a 5-second timespan.
