Skip to content

v1.0 Hide Vehicle Component

Choose a tag to compare

@DarkThymes DarkThymes released this 30 Jul 15:55
a5d1a64

Just make sure you have a team settings device in the world, compile your verse and then add your tags to your vehicle spawners and away you go. You could also use the code to add a custom vehicle mesh to the fort_character in the 'On Enter Vehicle' function

using { /Verse.org }
using { /Verse.org/Native }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation/Tags }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Vehicles }

vehicles := class(tag){}

hide_vehicle_component<public> := class<final_super>(component):
    RoundStart : event() = event(){}
    @editable Team : team_settings_and_inventory_device = team_settings_and_inventory_device{}
    var VehicleMap : [agent]fort_vehicle = map{}

    StartRound():void=
        RoundStart.Signal()

    OnEnterVehicle(Agent:agent):void=
        if:
            Vehicle:=Agent.GetFortCharacter[].GetVehicle[]
            set VehicleMap[Agent] = Vehicle
        then:
            set Vehicle.Show = false

    OnExitVehicle(Agent:agent):void=
        if:
            Vehicle:=VehicleMap[Agent]
        then:
            set Vehicle.Show = true
            var NewVehicleMap : [agent]fort_vehicle = map{}         
            for (Key -> Value : VehicleMap):
                if (Key <> Agent, set NewVehicleMap[Key] = Value):
            set VehicleMap = NewVehicleMap            

    
    OnSimulate<override>()<suspends>:void =
        if(Rounder := Entity.GetFortRoundManager[]):
            Rounder.SubscribeRoundStarted(StartRound)
        RoundStart.Await()
        Sleep(0.1)
        TaggedObjects := Team.FindCreativeObjectsWithTag(vehicles)
        for (TaggedObject:TaggedObjects, Spawner:= vehicle_spawner_device[TaggedObject]):
            Spawner.AgentEntersVehicleEvent.Subscribe(OnEnterVehicle)
            Spawner.AgentExitsVehicleEvent.Subscribe(OnExitVehicle)