using { /Fortnite.com/Devices } using { /Verse.org/Native } using { /Fortnite.com/Characters } using { /Verse.org/Random } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } using { /UnrealEngine.com/Temporary/SpatialMath } using { /Fortnite.com/Playspaces } CollectibleSystem := class(creative_device): @editable creatureSpawner : creature_spawner_device = creature_spawner_device{} # Reference to a creative_prop_asset array @editable var CoinsProp:[]creative_prop_asset := array{} # A map to store references to the spawned props. var SpawnedCoinsProps:[]creative_prop = array{} OnBegin<override>()<suspends>:void= creatureSpawner.EliminatedEvent.Subscribe(OnCreatureEliminated) Playspace : fort_playspace = GetPlayspace() AllPlayers := Playspace.GetPlayers() Print("About to LOOP " ) if (FirstPlayer := AllPlayers[0]): if (FortniteCharacter :fort_character = FirstPlayer.GetFortCharacter[]): loop: Sleep(1.0) Print("ENTER THE LOOP " ) PlayerPosition := FortniteCharacter.GetTransform().Translation for ( Prop : SpawnedCoinsProps): Proppos:=Prop.GetTransform().Translation thedistance:=Distance(PlayerPosition,Proppos) Print("Your distance prop is: " + ToString(thedistance)) if(thedistance <= 150.0): Prop.Hide() Prop.Dispose() OnCreatureEliminated(DeviceAIInteractionResult: device_ai_interaction_result):void= if (TargetAgent := DeviceAIInteractionResult.Target?, TargetFortCharacter:=TargetAgent.GetFortCharacter[]): spawnPos := TargetFortCharacter.GetTransform().Translation if: PropToSpawn := CoinsProp[0] # Use the first prop in the array for now SpawnedProp := SpawnProp(PropToSpawn, spawnPos, IdentityRotation()) if (SourceAgent := DeviceAIInteractionResult.Source?, FortCharacter:=SourceAgent.GetFortCharacter[]): var PlayerLocation : vector3 = FortCharacter.GetTransform().Translation distance:=Distance(spawnPos,PlayerLocation)
I’m trying to get an array of props spawned when Ennemies are elimated ( SpawnedCoinsProps)
to check in a loop if Player is closed enough to one of them to dispose the actual prop ( remove from the scene to add +1 coins in a gauge)
My problem :
I ‘m not succeeding in filling this array when the props are spawned.
I tryed different syntaxes and method but I’m struggling to find how to fix this little puzzle.