I’m making an Script to an object follow the player, but I want to switch the object to different players, but the SprintedEvent activates to all players that has the object before, there’s a way to do this? I tried some methods but nothing works.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
teste := class(creative_device):
@editable IdleAnim : cinematic_sequence_device = cinematic_sequence_device{}
@editable RunAnim : cinematic_sequence_device = cinematic_sequence_device{}
@editable Gatilho : trigger_device = trigger_device{}
@editable Gatilho2 : trigger_device = trigger_device{}
@editable FGChar : creative_prop = creative_prop{}
var On : logic = false
var CurrentAgent : ?agent = false
Raposa( A : ?agent) : void =
set CurrentAgent = A
Sim(A)
if(On = true):
if (P := A?, F := P.GetFortCharacter[]):
IdleAnim.Play()
F.SprintedEvent().Subscribe(OnMoved)
spawn:
UpdateCharacter(F, vector3{})
Sair( A : ?agent) : void =
if (A = CurrentAgent):
set On = false
set CurrentAgent = false
Sim( A : ?agent) : void=
if (A = CurrentAgent):
set On = true
OnBegin<override>()<suspends>:void=
Gatilho.TriggeredEvent.Subscribe(Raposa)
Gatilho2.TriggeredEvent.Subscribe(Sair)
UpdateCharacter(Player : fort_character, Offset : vector3)<suspends>:void=
loop:
Sleep(0.0)
NewPos := Player.GetTransform().Translation + Offset
if (FGChar.TeleportTo[NewPos, Player.GetTransform().Rotation]) {}
if (On = false):
break
OnMoved(MoveData : tuple(fort_character, logic)):void=
if (Agent := MoveData(0).GetAgent[]):
if (Agent = CurrentAgent):
if (MoveData(1)?):
IdleAnim.Stop(Agent)
RunAnim.Play(Agent)
else:
RunAnim.Stop(Agent)
IdleAnim.Play(Agent)