the following code is adapted from a great tutorial by Graeme Bull, although in his tutorial he only goes as far as the first function ‘OnLootBoxButton’… the and the custom loot box work fine in this regard.
When I tried to duplicate the loot box, I added ‘OnLootBoxButton2’ … for some reason when I trigger the first loot box the second one also triggers, despite being in a different location. If I try to go to the second loot box without triggering the first loot box I don’t even get the option to interact with the second loot box.
I am hoping that someone can help with this and explain to me what I am doing wrong…
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
GameManager := class(creative_device):
@editable
PS1:player_spawner_device = player_spawner_device{}
@editable
LootBoxButton: button_device = button_device{}
@editable
LootBoxLid: creative_prop = creative_prop{}
@editable
LootGranter: item_granter_device = item_granter_device{}
@editable
VFX: vfx_spawner_device = vfx_spawner_device{}
@editable
LootBoxButton2: button_device = button_device{}
@editable
LootBoxLid2: creative_prop = creative_prop{}
@editable
LootGranter2: item_granter_device = item_granter_device{}
@editable
VFX2: vfx_spawner_device = vfx_spawner_device{}
OnBegin<override>()<suspends>:void=
LootBoxButton.InteractedWithEvent.Subscribe(OnLootBoxButton)
LootBoxButton2.InteractedWithEvent.Subscribe(OnLootBoxButton2)
OnLootBoxButton(Agent: agent): void=
spawn:
RotateBoxLid(Agent)
RotateBoxLid(Agent: agent)<suspends>:void=
#disable the button
LootBoxButton.Disable()
loop:
LidTransform:transform = LootBoxLid.GetTransform()
Rotation:rotation=LidTransform.Rotation
LootBoxLid.MoveTo(LidTransform.Translation, Rotation.ApplyLocalRotationY(1.0), 0.5)
NewRotation:rotation=LidTransform.Rotation
YPR:= NewRotation.GetYawPitchRollDegrees()
if(YPR[0] >= -90.0):
LootGranter.GrantItem(Agent)
VFX.Disable()
break
OnLootBoxButton2(Agent: agent): void=
spawn:
RotateBoxLid2(Agent)
RotateBoxLid2(Agent: agent)<suspends>:void=
#disable the button
LootBoxButton2.Disable()
loop:
LidTransform:transform = LootBoxLid2.GetTransform()
Rotation:rotation=LidTransform.Rotation
LootBoxLid2.MoveTo(LidTransform.Translation, Rotation.ApplyLocalRotationY(1.0), 0.5)
NewRotation:rotation=LidTransform.Rotation
YPR:= NewRotation.GetYawPitchRollDegrees()
if(YPR[0] >= -90.0):
LootGranter2.GrantItem(Agent)
VFX.Disable()
break