Hello, I’m here to share my code for a vehicle spawner. This spawner allows you to use a conditional button to check if they holding a card then spawn a vehicle. I also added a special bit where a movement modulator will spawn under the card once spawned!
Initially I wanted to create some simulator but didn’t get the chance so have fun!
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/SpatialMath }
CarSpawnerHandler := class(creative_device):
@editable var SportsCarSpawner : vehicle_spawner_sports_car_device = vehicle_spawner_sports_car_device{}
@editable var SportsCarButton : conditional_button_device = conditional_button_device{}
@editable var MovementModulator : movement_modulator_device = movement_modulator_device{}
var WasHoldingCard :int = 0
AgentEntersVehicle(Agent:agent):void=
ApplySpeedBoost(Agent)
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
SportsCarSpawner.AgentEntersVehicleEvent.Subscribe(AgentEntersVehicle)
spawn{CarSpawnersLoop()}
CarSpawnersLoop()<suspends>:void=
loop:
Sleep(1.0)
AllPlayers := GetPlayspace().GetPlayers()
for (Player : AllPlayers):
CheckForCard(SportsCarButton, SportsCarSpawner, Player)
CheckForCard(CardDetector:conditional_button_device, CarSpawner:vehicle_spawner_device, Agent:agent)<suspends>:void=
if:
CardDetector.IsHoldingItem[Agent]
then:
if:
FortCharacter := Agent.GetFortCharacter[]
FCTransform:=FortCharacter.GetTransform()
WasHoldingCard <> 1
then:
DespawnAllVehicle()
Print("Car Spawned")
CarSpawner.RespawnVehicle()
if (CarSpawner.TeleportTo[FCTransform.Translation, FCTransform.Rotation]):
Print("Car Teleported")
set WasHoldingCard = 1
Sleep(1.0)
else:
set WasHoldingCard = 0
DespawnAllVehicle():void=
SportsCarSpawner.DestroyVehicle()
Print("All Cars Destroyed")
ApplySpeedBoost(Agent:agent):void=
if:
FortCharacter := Agent.GetFortCharacter[]
FCTransform:=FortCharacter.GetTransform()
then:
if (MovementModulator.TeleportTo[FCTransform.Translation, FCTransform.Rotation]):
Print("Speed Boost Applied")
SpeedBoostManager := class(creative_device):
@editable var SpeedBoost : movement_modulator_device = movement_modulator_device{}
OnActivationEvent(Agent:agent):void=
OriginPosition:= vector3{X:=0.0, Y:=0.0, Z:=0.0}
if (SpeedBoost.TeleportTo[OriginPosition, IdentityRotation()]):
Print("Returning Back To Origin")
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
SpeedBoost.ActivationEvent.Subscribe(OnActivationEvent)