Hi! I’m making a game in UEFN where the player has cool abilities and powers! this code below works fine when there’s only one player testing it, however, does not work with 2 or more people.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }
using {/UnrealEngine.com/Temporary/SpatialMath}
# A Verse-authored creative device that can be placed in a level
Power_Device := class(creative_device):
# Powers
@editable
Speedster : player_spawner_device = player_spawner_device{}
@editable
Ninja : player_spawner_device = player_spawner_device{}
@editable
Jumpster : player_spawner_device = player_spawner_device{}
# Devices
@editable
Ninja_Mutator : mutator_zone_device = mutator_zone_device{}
@editable
Speedster_Mutator : mutator_zone_device = mutator_zone_device{}
@editable
ninja_indicator : map_indicator_device = map_indicator_device{}
var IsNinja : logic = false
var IsSpeedster : logic = false
var IsJumpster : logic = false
var InvisibilityState : int = 0
var IsSprinting : logic = true
var Tracking : logic = false
Sprint(Agent:fort_character,Logic:logic) : void=
if (IsSprinting?):
Print("Speed!")
Speedster_Mutator.Enable()
set IsSprinting = false
else:
Print("Slow :(")
Speedster_Mutator.Disable()
set IsSprinting = true
Crouched(Agent:fort_character,Logic:logic) : void =
if (InvisibilityState <> 1):
Print("Invisible")
Agent.Hide()
Ninja_Mutator.Enable()
set InvisibilityState = 1
set Tracking = true
ninja_indicator.Enable()
spawn:
EventTick(Agent)
else:
Print("Visible")
Agent.Show()
Ninja_Mutator.Disable()
set InvisibilityState = 0
set Tracking = false
ninja_indicator.Disable()
CLASSCHECK(Agent:agent) : void =
var SpeedsterTeam : int = 2
var NinjaTeam : int = 1
var JumpsterTeam : int = 0
TeamCollection := GetPlayspace().GetTeamCollection()
if:
AgentsTeam := TeamCollection.GetTeam[Agent]
then:
TeamsArray := TeamCollection.GetTeams()
for (TeamNumber -> Team : TeamsArray):
if (AgentsTeam = Team):
if (Fort_Character := Agent.GetFortCharacter[]):
if (TeamNumber = SpeedsterTeam):
set IsSpeedster = true
else if (TeamNumber = NinjaTeam):
set IsNinja = true
else if(TeamNumber = JumpsterTeam):
set IsJumpster = true
else:
Print("ERROR: TEAM WAS NONE")
loop:
if (IsSpeedster?):
Print("Speedy")
Fort_Character.SprintedEvent().Subscribe(Sprint)
else if(IsNinja?):
Print("Hidey")
Fort_Character.CrouchedEvent().Subscribe(Crouched)
else if(IsJumpster?):
Print("Jumpy")
break
EventTick(Agent:fort_character)<suspends> : void=
var MaybeTeam2 : ?team = option{GetPlayspace().GetTeamCollection().GetTeams()[1]}
loop:
Sleep(5.0)
if (Tracking = false){
break
}
Ninja_Location := Agent.GetTransform()
if (ninja_indicator.TeleportTo[Ninja_Location]):
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Print("Initialised")
Speedster.SpawnedEvent.Subscribe(CLASSCHECK)
Jumpster.SpawnedEvent.Subscribe(CLASSCHECK)
Ninja.SpawnedEvent.Subscribe(CLASSCHECK)
I genuinely have 0 idea’s on how to fix this. Please help!
To be more specific with the issues. I want each player to have their own power, two players cannot have the same power. but when i ran it, it set everyone to the same power.