Summary
Default value for a variable on a custom component is not being set when dynamically spawning a new prefab instance from a device.
Please select what you are reporting on:
Unreal Editor for Fortnite
What Type of Bug are you experiencing?
Verse
Steps to Reproduce
- Create a custom component and add a logic variable set to true by default:
test_component<public> := class<final_super>(component):
var IsEnabled : logic := true
- Create a prefab that has a child entity containing the custom component.
- Create a custom device to spawn multiple prefabs:
custom_device := class(creative_device):
OnBegin<override>()<suspends>:void=
if (SimulationEntity := GetSimulationEntity[]):
# Spawn 10 prefabs
for(Index := 0..9):
# Creating a new prefab instance and setting to device location
CustomPrefab:Prefab_Custom := Prefab_Custom{}
CustomPrefab.SetGlobalTransform(FromTransform(GetTransform())
# Iterate over child entities to find the custom component
for (EntityFound : CustomPrefab.GetEntities()):
if (TestComponent := EntityFound.GetComponent[test_component]):
if (TestComponent.IsEnabled = false):
Print("TestComponent.IsEnabled is false by default?")
Expected Result
IsEnabled would be set to true.
Observed Result
IsEnabled is set to false.
Platform(s)
PC
Additional Notes
I’m not sure if this is happening for default values of other types, if it is localized only to components, etc. Noticed this on a custom component and I am now checking other classes where we set default values for variables.