Summary
Child entities of a prefab in UEFN cannot be manipulated through tag when the prefab is spawned. Movement and rotation consistently fail
Please select what you are reporting on:
Verse
What Type of Bug are you experiencing?
Verse
Steps to Reproduce
-
Create a Prefabs folder and create a Prefab inside the folder called Prefab_RotatingCube with two entities, Parent(main root entity) and Child(Attached to Parent).
-
Make sure both entities in the prefab contain transform, custom mesh, keyframe and tag components. Custom mesh should have a custom imported mesh for both the entities, move the child entity up so you can see both the custom meshes
-
Create a verse Component C_RotateEntity.
-
Go to C_RotateEntity verse file and copy this code(This code also creates a tag):
using { /Verse.org }
using { /Verse.org/Native }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /Verse.org/SceneGraph/KeyframedMovement }
using { /Verse.org/SpatialMath }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation/Tags }
rotate := class(tag):
A Verse-authored component that can be added to entities
C_RotateEntity := class<final_super>(component):
# Runs when the component should start simulating in a running game.
OnBeginSimulation<override>():void =
# Run OnBeginSimulation from the parent class before
# running this component's OnBeginSimulation logic
(super:)OnBeginSimulation()
# We rotate entity at the start
spawn:
Rotate()
# Runs when the component should start simulating in a running game.
# Can be suspended throughout the lifetime of the component. Suspensions
# will be automatically cancelled when the component is disposed or the
# game ends.
OnSimulate<override>()<suspends>:void =
# TODO: Place simple suspends logic to run for this component here
block:
Rotate()<suspends>:void=
loop:
Sleep(1.0)
EntityGen := Entity.FindDescendantEntitiesWithTag(rotate{})
for(TaggedEntity : EntityGen):
Print("Attempt Rotation")
if (KeyFrame := TaggedEntity.GetComponent[keyframed_movement_component]):
# New transform to move to. We are rotating the entity
InTransform : (/Verse.org/SpatialMath:)transform = (/Verse.org/SpatialMath:)transform:
Translation:= (/Verse.org/SpatialMath:)vector3{Forward:=0.0,Right:=0.0, Up:=0.0}
Rotation := (/Verse.org/SpatialMath:)MakeRotationFromYawPitchRollDegrees(10.0, 0.0, 0.0) # Rotate 10 units per second
Scale:= (/Verse.org/SpatialMath:)vector3{Forward := 1.0,Right := 1.0, Up := 1.0}
KeyFrames : keyframed_movement_delta = keyframed_movement_delta:
Transform := InTransform
Duration := 1.0
KeyFrame.SetKeyframes(array{KeyFrames}, oneshot_keyframed_movement_playback_mode{})
KeyFrame.Play()
- Create a verse device called V_EntitySpawner and copy this code:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/SceneGraph }
using { /Verse.org/SpatialMath }
A Verse-authored creative device that can be placed in a level
V_EntitySpawner := class(creative_device):
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
# TODO: Replace this with your code
Sleep(1.0)
Spawn()
Spawn()<suspends>:void=
if(SimulationEntity := GetSimulationEntity[]):
Transform := FromTransform(GetTransform())
# Create and place Tower
Print("Spawn Tower")
Tower : Prefabs.Prefab_RotatingCube = Prefabs.Prefab_RotatingCube{}
SimulationEntity.AddEntities(array{Tower})
Sleep(0.0)
Print("Set Tower Transform")
Tower.SetGlobalTransform((/Verse.org/SpatialMath:)transform{Translation := Transform.Translation, Rotation := Transform.Rotation, Scale := Tower.GetGlobalTransform().Scale})
-
Add C_RotateEntity component to Root Entity in the prefab. Add Rotate tag for Child entity in the prefab
-
Build verse, Put an empty entity in the scene(This makes sure the function GetSimulation doesnt fail)
-
Put the verse spawner device in the level, beside it put the Prefab_RotatingCube beside it
-
Play
Expected Result
Prefab spawns on the device. Child entity on the prefab thats placed by hand will rotate and child entity of spawned prefab will also rotate
Observed Result
Prefab spawns on the device. Child entity on the prefab thats placed by hand will rotate but child entity of spawned prefab will not rotate
Platform(s)
PC
Video
Additional Notes
If you remove the rotate tag in the child entity of prefab and put that tag on the parent entity of the prefab then push/play. You will see that spawned prefab does rotate. So the bug is only on child entities of a prefab?