Hello, I am a beginner in Verse.
I am trying to make a trigger spawn right in front of player when eliminating but somehow can’t get the code right. can someone please help. thank you.
Here is the code I have right now. (Sorry it’s so messy.)
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
See Create Your Own Device Using Verse in Unreal Editor for Fortnite | Unreal Editor for Fortnite Documentation | Epic Developer Community for how to create a verse device.
A Verse-authored creative device that can be placed in a level
hello_world_device := class(creative_device):
@editable
Trigger : trigger_device = trigger_device{}
@editable
EliminateManager : elimination_manager_device = elimination_manager_device{}
@editable
P1Spawner:player_spawner_device = player_spawner_device{}
@editable
P2Spawner:player_spawner_device = player_spawner_device{}
OnBegin<override>()<suspends>:void=
P1Spawner.SpawnedEvent.Subscribe(OnPlayerSpawned)
P2Spawner.SpawnedEvent.Subscribe(OnPlayerSpawned)
AttatchToPlayerNew(Agent : agent)<suspends> : void=
if(FC := Agent.GetFortCharacter[]):
loop:
Sleep(0.0)
PlayerPos := FC.GetTransform().Translation
PlayerRot := FC.GetTransform().Rotation
Trigger.MoveTo(PlayerPos,PlayerRot,0.1)
OnPlayerSpawned(Agent:agent):void=
if(FC:fort_character = Agent.GetFortCharacter[]):
FC.EliminatedEvent().Subscribe(OnPlayerEliminated)
OnPlayerEliminated(ElimResult:elimination_result):void=
Print("somebody got elim")
EliminatedFC:fort_character = ElimResult.EliminatedCharacter
if(FortCharacter := ElimResult.EliminatingCharacter?):
if(FortCharacter = EliminatedFC):
if(SelfElimAgent:agent = FortCharacter.GetAgent[]):
else:
if(EliminatingAgent := FortCharacter.GetAgent[], EliminatingPlayer :=player[EliminatingAgent]):
AttatchToPlayerNew(EliminatingAgent)