It doesn't work even though there are no errors, please tell me.

I’ve written a Verse code to go to the area I’m getting when I press the button, but it doesn’t work, I don’t know what’s wrong, so please tell me.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Simulation/Tags }
using { /Fortnite.com/Characters}
using { /Fortnite.com/FortPlayerUtilities }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Teams }

respawn_manager := class(creative_device):
    var CaptureWeightOfThisPoint1A:int = 0
    var PlayerWeightOfThisPoint1A:float = 0.0
    var WeightOfPoint1A:float = 0.0
    var CaptureWeightOfThisPoint1B:int = 0
    var PlayerWeightOfThisPoint1B:float = 0.0
    var WeightOfPoint1B:float = 0.0
    var CaptureWeightOfThisPoint1C:int = 0
    var PlayerWeightOfThisPoint1C:float = 0.0
    var WeightOfPoint1C:float = 0.0
    var CaptureWeightOfThisPoint2A:int = 0
    var PlayerWeightOfThisPoint2A:float = 0.0
    var WeightOfPoint2A:float = 0.0
    var CaptureWeightOfThisPoint2B:int = 0
    var PlayerWeightOfThisPoint2B:float = 0.0
    var WeightOfPoint2B:float = 0.0
    var CaptureWeightOfThisPoint2C:int = 0
    var PlayerWeightOfThisPoint2C:float = 0.0
    var WeightOfPoint2C:float = 0.0

    WeightForEachPlayer:float = 0.5
    





    #@editable ButtonTeam1I : button_device = button_device{}
    @editable ButtonTeam1A : button_device = button_device{}
    @editable ButtonTeam1B : button_device = button_device{}
    @editable ButtonTeam1C : button_device = button_device{}
    @editable ButtonTeam2A : button_device = button_device{}
    @editable ButtonTeam2B : button_device = button_device{}
    @editable ButtonTeam2C : button_device = button_device{}

    @editable CapturePoint1A : capture_area_device = capture_area_device{}
    @editable CapturePoint1B : capture_area_device = capture_area_device{}
    @editable CapturePoint1C : capture_area_device = capture_area_device{}
    @editable CapturePoint2A : capture_area_device = capture_area_device{}
    @editable CapturePoint2B : capture_area_device = capture_area_device{}
    @editable CapturePoint2C : capture_area_device = capture_area_device{}


    @editable LargeZone1A : player_counter_device =player_counter_device{}
    @editable LargeZone1B : player_counter_device =player_counter_device{}
    @editable LargeZone1C : player_counter_device =player_counter_device{}
    @editable LargeZone2A : player_counter_device =player_counter_device{}
    @editable LargeZone2B : player_counter_device =player_counter_device{}
    @editable LargeZone2C : player_counter_device =player_counter_device{}

    @editable Spawn : player_spawner_device = player_spawner_device{}
    @editable Spawn2 : player_spawner_device = player_spawner_device{}
    @editable Spawn3 : player_spawner_device = player_spawner_device{}
    @editable Spawn4 : player_spawner_device = player_spawner_device{}
    @editable Spawn5 : player_spawner_device = player_spawner_device{}
    @editable Spawn6 : player_spawner_device = player_spawner_device{}
	# If Team 1, we return 1.  If Team 2, we return -1.
    GetTeamDirectionOfAgent<private>(MyAgent:agent)<transacts>:int=
        TeamCollectionRef:=GetPlayspace().GetTeamCollection()
        if (FirstTeam := TeamCollectionRef.GetTeams()[0]):
            if (TeamCollectionRef.IsOnTeam[MyAgent, FirstTeam]):
                return 1
        return -1
                
    
    Capture1A(MyAgent:agent):void=
        set CaptureWeightOfThisPoint1A = GetTeamDirectionOfAgent(MyAgent)

    Capture1B(MyAgent:agent):void=
        set CaptureWeightOfThisPoint1B = GetTeamDirectionOfAgent(MyAgent)

    Capture1C(MyAgent:agent):void=
        set CaptureWeightOfThisPoint1C = GetTeamDirectionOfAgent(MyAgent)
        
    Capture2A(MyAgent:agent):void=
        set CaptureWeightOfThisPoint2A = GetTeamDirectionOfAgent(MyAgent)
        
    Capture2B(MyAgent:agent):void=
        set CaptureWeightOfThisPoint2B = GetTeamDirectionOfAgent(MyAgent)

    Capture2C(MyAgent:agent):void=
        set CaptureWeightOfThisPoint2C = GetTeamDirectionOfAgent(MyAgent)    

    # Shift player weighting of point as players enter or leave
    CountedZone1A(MyAgent:agent):void=
        set PlayerWeightOfThisPoint1A = PlayerWeightOfThisPoint1A + (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
    RemovedZone1A(MyAgent:agent):void=
        set PlayerWeightOfThisPoint1A = PlayerWeightOfThisPoint1A - (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)

    CountedZone1B(MyAgent:agent):void=
        set PlayerWeightOfThisPoint1B = PlayerWeightOfThisPoint1B + (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
    RemovedZone1B(MyAgent:agent):void=
        set PlayerWeightOfThisPoint1B = PlayerWeightOfThisPoint1B - (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)

    CountedZone1C(MyAgent:agent):void=
        set PlayerWeightOfThisPoint1C = PlayerWeightOfThisPoint1C + (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
    RemovedZone1C(MyAgent:agent):void=
        set PlayerWeightOfThisPoint1C = PlayerWeightOfThisPoint1C - (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)

    CountedZone2A(MyAgent:agent):void=
        set PlayerWeightOfThisPoint2A = PlayerWeightOfThisPoint2A + (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
    RemovedZone2A(MyAgent:agent):void=
        set PlayerWeightOfThisPoint2A = PlayerWeightOfThisPoint2A - (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)

    CountedZone2B(MyAgent:agent):void=
        set PlayerWeightOfThisPoint2B = PlayerWeightOfThisPoint2B + (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
    RemovedZone2B(MyAgent:agent):void=
        set PlayerWeightOfThisPoint2B = PlayerWeightOfThisPoint2B - (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)

    CountedZone2C(MyAgent:agent):void=
        set PlayerWeightOfThisPoint2C = PlayerWeightOfThisPoint2C + (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)
    RemovedZone2C(MyAgent:agent):void=
        set PlayerWeightOfThisPoint2C = PlayerWeightOfThisPoint2C - (GetTeamDirectionOfAgent(MyAgent) * WeightForEachPlayer)

    OnBegin<override>()<suspends>:void=
        #ButtonTeam1I.InteractedWithEvent.Subscribe(ButtonInteractedHandler)
        ButtonTeam1A.InteractedWithEvent.Subscribe(ButtonSpawn1A)
        ButtonTeam1B.InteractedWithEvent.Subscribe(ButtonSpawn1B)
        ButtonTeam1C.InteractedWithEvent.Subscribe(ButtonSpawn1C)
        ButtonTeam2A.InteractedWithEvent.Subscribe(ButtonSpawn2A)
        ButtonTeam2B.InteractedWithEvent.Subscribe(ButtonSpawn2B)
        ButtonTeam2C.InteractedWithEvent.Subscribe(ButtonSpawn2C)

        CapturePoint1A.ControlChangeEvent.Subscribe(Capture1A)
        LargeZone1A.CountedEvent.Subscribe(CountedZone1A)
        LargeZone1A.RemovedEvent.Subscribe(RemovedZone1A)

        CapturePoint1B.ControlChangeEvent.Subscribe(Capture1B)
        LargeZone1B.CountedEvent.Subscribe(CountedZone1B)
        LargeZone1B.RemovedEvent.Subscribe(RemovedZone1B)

        CapturePoint1C.ControlChangeEvent.Subscribe(Capture1C)
        LargeZone1C.CountedEvent.Subscribe(CountedZone1C)
        LargeZone1C.RemovedEvent.Subscribe(RemovedZone1C)

        CapturePoint2A.ControlChangeEvent.Subscribe(Capture2A)
        LargeZone2A.CountedEvent.Subscribe(CountedZone2A)
        LargeZone2A.RemovedEvent.Subscribe(RemovedZone2A)

        CapturePoint2B.ControlChangeEvent.Subscribe(Capture2B)
        LargeZone2B.CountedEvent.Subscribe(CountedZone2B)
        LargeZone2B.RemovedEvent.Subscribe(RemovedZone2B)

        CapturePoint2C.ControlChangeEvent.Subscribe(Capture2C)
        LargeZone2C.CountedEvent.Subscribe(CountedZone2C)
        LargeZone2C.RemovedEvent.Subscribe(RemovedZone2C)

        Spawn.Enable()
        Spawn2.Enable()
        Spawn3.Enable()
        Spawn4.Enable()
        Spawn5.Enable()
        Spawn6.Enable()

    #ButtonInteractedHandler(Agent:agent): void=
    #    if(FortCharacter := Agent.GetFortCharacter[]):
    #       FortCharacter.Damage(150.0) 
    #        Agent.Respawn(vector3{X := 2570.0, Y := -6180.0, Z := 2690.0},IdentityRotation())
    ButtonSpawn1A(Agent:agent): void=
        set WeightOfPoint1A = PlayerWeightOfThisPoint1A + PlayerWeightOfThisPoint1A
        if(WeightOfPoint1A > 0.0):
            if(FortCharacter := Agent.GetFortCharacter[]):
                FortCharacter.Damage(150.0) 
                Agent.Respawn(vector3{X := 11010.0, Y := -1533.0, Z := 3064.0},IdentityRotation())

    ButtonSpawn1B(Agent:agent): void=
        set WeightOfPoint1B = PlayerWeightOfThisPoint1B + PlayerWeightOfThisPoint1B
        if(WeightOfPoint1B > 0.0):
            if(FortCharacter := Agent.GetFortCharacter[]):
                FortCharacter.Damage(150.0) 
                Agent.Respawn(vector3{X := 1923.5, Y := 1063.0, Z := 2680.0},IdentityRotation())

    ButtonSpawn1C(Agent:agent): void=
        set WeightOfPoint1C = PlayerWeightOfThisPoint1C + PlayerWeightOfThisPoint1C
        if(WeightOfPoint1C > 0.0):
            if(FortCharacter := Agent.GetFortCharacter[]):
                FortCharacter.Damage(150.0) 
                Agent.Respawn(vector3{X := -6950.0, Y := 2848.0, Z := 2872.0},IdentityRotation())

    ButtonSpawn2A(Agent:agent): void=
        set WeightOfPoint2A = PlayerWeightOfThisPoint2A + PlayerWeightOfThisPoint2A
        if(WeightOfPoint2A < 0.0):
            if(FortCharacter := Agent.GetFortCharacter[]):
                FortCharacter.Damage(150.0) 
                Agent.Respawn(vector3{X := 11010.0, Y := -1533.0, Z := 3064.0},IdentityRotation())

    ButtonSpawn2B(Agent:agent): void=
        set WeightOfPoint2B = PlayerWeightOfThisPoint2B + PlayerWeightOfThisPoint2B
        if(WeightOfPoint2B < 0.0):
            if(FortCharacter := Agent.GetFortCharacter[]):
                FortCharacter.Damage(150.0) 
                Agent.Respawn(vector3{X := 1923.5, Y := 1063.0, Z := 2680.0},IdentityRotation())
    
    ButtonSpawn2C(Agent:agent): void=
        set WeightOfPoint2C = PlayerWeightOfThisPoint2C + PlayerWeightOfThisPoint2C
        if(WeightOfPoint2C < 0.0):
            if(FortCharacter := Agent.GetFortCharacter[]):
                FortCharacter.Damage(150.0) 
                Agent.Respawn(vector3{X := -6950.0, Y := 2848.0, Z := 2872.0},IdentityRotation())

If there are no compile errors, there can still be logic errors in what we’re trying to do. Do you mean you are trying to move players from one point to another and they are not getting moved to that point? What happens when you try the button, anything? Does the player respawn anywhere at all or there’s no visual change?

I see you’re enabling player spawner devices and having the button spawn functions attempt to respawn the player. Is there a spawn limit on the Island settings?

When I’m debugging things in my code, I often put a lot of Print("say some message here") functions in my functions, if statements, and other parts I expect to execute, etc. That can help narrow down where the error is happening, because it lets us see in the output Log screen if we’re reaching those points in the code execution.
For example you can put some here:

    ButtonSpawn1A(Agent:agent): void=
        Print("Starting function ButtonSpawn1A ---")
        set WeightOfPoint1A = PlayerWeightOfThisPoint1A + PlayerWeightOfThisPoint1A
        if(WeightOfPoint1A > 0.0):
            Print("if(WeightOfPoint1A > 0.0) = true")
            if(FortCharacter := Agent.GetFortCharacter[]):
                Print("Begin Agent.Respawn")
                FortCharacter.Damage(150.0) 
                Agent.Respawn(vector3{X := 11010.0, Y := -1533.0, Z := 3064.0},IdentityRotation())

I would start with Print functions and see if they all trigger first

Also did you mean to write this?
set WeightOfPoint1A = PlayerWeightOfThisPoint1A + PlayerWeightOfThisPoint1A

I notice it’s adding the same variable twice as the result for WeightOfPoint1A.

1 Like

The code calls Agent.Respawn() to try and move them, I have no experience with that. What I do is a TeleportTo() call on the FortCharacter, which I use a lot.

2 Likes

Right off the bat this code is very repetitive and messy, which will give you many errors down the line. I recommend learning about how to create classes to store data instead of repeating variables over and over again, this will save you tons of work and bugs. Something like this:

CapturePoint := class<concrete>(): #Concrete so you can make editable
     @editable device : capture_area_device = capture_area_device{}
     var CaptureWeight : int = 0
     var PlayerWeight : float = 0.0
     var Weight : float = 0.0
#store these in an array or map
@editable CapturePoints : []CapturePoint = array{}
#you can also use multidimensional arrays to store multiple capture points under one index
CapturePoints : [][]CapturePoint = array{array{}}
2 Likes

Thanks to all of you, we were able to partially teleport. But I still can’t teleport partially, and when I checked the logs, I found the following error.

LogVerse: Warning: Game_teleport_to_debug_log: (Rolling Back) TeleportTo error: Something is colliding with the requested destination, target destination: {Scale: {x=1.000000,y=1.000000,z=1.000000} Rotation: {Axis: {x=1.000000,y=0.000000,z=0.000000} Angle: 0.000000} Translation: {x=11010.000000,y=-1533.000000,z=3064.000000}}.

We would be grateful if you could tell us how to solve this problem.

1 Like

In my experience this means your teleport destination has something (maybe a wall) which would be a collision.

I’ve had this happen, but when I ‘fixed’ my teleport location (transform) it was fine, so I don’t know the details on what counts as a collision to prevent a teleport and what doesn’t.

1 Like

Yeah they might just be colliding with the floor, try teleporting them higher or just using a teleporter device

1 Like

When I teleport my NPCs I was adding around 75.0 to the Z coord so they don’t collide with the floor.

More recently I’ll drop an FN Mannequin where I want to teleport them to, and check it’s transform (and then add a bit to Z just to be safe).

1 Like

Thanks to all of you, we were able to solve the problem, and we sincerely appreciate your help. Thank you very much.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.