Skip to content

PathManager

Latest

Choose a tag to compare

@DarkThymes DarkThymes released this 12 Jun 10:17
7556534

Extract everything to your content folder, compile verse and then add an entity to the scene and add the path manager component

using { /Fortnite.com }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/AI }
using { /Fortnite.com/Devices/CreativeAnimation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/SceneGraph }
using { /Verse.org }
using { /Verse.org/Assets }
using { /Verse.org/Colors }
using { /Verse.org/Concurrency }
using { /Verse.org/Native }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
using { /Verse.org/Colors/NamedColors }
using { /Verse.org/SceneGraph/KeyframedMovement }
using { /Verse.org/SpatialMath }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/Playspaces }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Game }

ePath := enum{Entity, Prop, Location}

path :=class:
    @editable EndType : ePath = ePath.Entity
    @editable EntityEnd : entity = entity{}
    @editable PropEnd : creative_prop = creative_prop{}
    @editable VectorEnd : vector3 = vector3{}
    @editable ActivateTrigger : trigger_device = trigger_device{}
    @editable NextTrigger : ?trigger_device = false

path_manager_component<public> := class<final_super>(component):
    @editable Paths : []path = array{}
    RoundStart : event() = event(){}

    TriggerAwait(Path:path)<suspends>:void=
        loop:
            mAgent:=Path.ActivateTrigger.TriggeredEvent.Await()
            if:
                FC:=mAgent?.GetFortCharacter[]
                FCEnt:=FC.GetEntity[]
            then:
                DoPath(Path, FC, FCEnt)
            Sleep(0.0)

    DoPath(Path:path, FC:fort_character, FCEnt:entity):void=
        NewPath:entity=entity{}
        VFXComp:NS_Path=NS_Path{Entity:=NewPath}
        NewPath.AddComponents(array{VFXComp})
        FCEnt.AddEntities(array{NewPath})
        NewPath.SetLocalTransform(transform{Translation:=vector3{Up:=-50.0}})
        if. Player:= player[FC.GetAgent[]] then NewPath.SetPresentableToPlayers(option. array{Player})
        case(Path.EndType):
            ePath.Entity=>
                EntLoc:=Path.EntityEnd.GetGlobalTransform().Translation
                set VFXComp.vEnd = EntLoc
                spawn. EndCheck (Path, FC, FCEnt, EntLoc, VFXComp)
            ePath.Prop=>
                PropLoc := Path.PropEnd.GetGlobalTransform().Translation
                set VFXComp.vEnd = PropLoc
                spawn. EndCheck (Path, FC, FCEnt, PropLoc, VFXComp)
            ePath.Location=>
                set VFXComp.vEnd = Path.VectorEnd
                spawn. EndCheck (Path, FC, FCEnt, Path.VectorEnd, VFXComp)


    EndCheck(Path:path, FC:fort_character, FCEnt:entity, EndLoc:vector3, VFXComp:NS_Path)<suspends>:void=
        loop:
            CurrentDistSq:=DistanceSquared(FCEnt.GetGlobalTransform().Translation, EndLoc)
            if:
                CurrentDistSq < 75000.0
                Agent:=FC.GetAgent[]
            then:
                VFXComp.Stop()
                VFXComp.Entity.RemoveFromParent()
                if. Next:=Path.NextTrigger? then Next.Trigger(Agent)
            Sleep(0.0)

    StartRound():void=
        RoundStart.Signal()

    OnBeginSimulation<override>():void =
        (super:)OnBeginSimulation()
    
    OnSimulate<override>()<suspends>:void =
        if(Rounder := Entity.GetFortRoundManager[]):
            Rounder.SubscribeRoundStarted(StartRound)
        RoundStart.Await()
        for (Path:Paths):
            spawn. TriggerAwait(Path)