Anyone able to help me with this?

I am trying to get the “get closest player” Implemented into my rotate and move to. any help is appreciated. I have tried many things and always end in errors.

MoveAnimation():void=
WalkCinema.Play()
ClosestPlayer := GetPlayspace().GetPlayers()
if (Player := ClosestPlayer[0], Agent := agent[Player], Fort := Agent.GetFortCharacter):
PlayerTran := Fort.GetTransform()
Boss.MoveTo(PlayerTran.Translation - vector3{Z:=95.0}, Boss.GetTransform().Rotation, 3.0)

RotateTowardPlayer()<suspends>:void=
    ClosestPlayer:[]player = GetPlayspace().GetPlayers()
    if (Player := ClosestPlayer, Agent := agent[Player], Fort := Agent.GetFortCharacter[]):

        PropLocation := Boss.GetTransform().Translation
        PlayerLocation := Fort.GetTransform().Translation

        if (LookDirection := (PlayerLocation - PropLocation).MakeUnitVector[]):

            #Z axis
            Yaw := RadiansToDegrees(ArcTan(LookDirection.Y, LookDirection.X)) - 90.0
            #Y axis
            Pitch := 0.0
            #X axis
            Roll := 0.0

            NewRotation := MakeRotationFromYawPitchRollDegrees(Yaw, Pitch, Roll)

            Boss.MoveTo(Boss.GetTransform().Translation, NewRotation, 3.0)

GetClosestPlayer(AllPlayers: []fort_character, Prop : creative_prop): ?fort_character =
    var ClosestPlayer : ?fort_character = false
    var ClosestDistance: float = 1000000000.0 # initialize with a large number
    for (Player : AllPlayers):
        EDistance := Distance(Boss.GetTransform().Translation, Player.GetTransform().Translation)
        if (EDistance < ClosestDistance):
            set ClosestPlayer = option{Player}
            set ClosestDistance = EDistance
    return ClosestPlayer

Hey, try to replace this

    if (Player := ClosestPlayer, Agent := agent[Player], Fort := Agent.GetFortCharacter[]):

By this

    if (Player := ClosestPlayer(GetPlayspace().GetPlayers(), Boss), Agent := agent[Player], Fort := Agent.GetFortCharacter[]):

This is the first thing that comes into my mind, but maybe there’s more to do, you tell me.

Thank you very much with the quick response. I did that and have a new error. Would you like to see the full code?

using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath}
using { /Fortnite.com/Playspaces }

skele_boss_fight := class(creative_device):

@editable Zonedevice : mutator_zone_device = mutator_zone_device{}
@editable GroundAtackCinema : cinematic_sequence_device = cinematic_sequence_device{}
@editable GroundAtackCinema2 : cinematic_sequence_device = cinematic_sequence_device{}
@editable GroundAtackCinema3 : cinematic_sequence_device = cinematic_sequence_device{}
@editable GroundAtackCinema4 : cinematic_sequence_device = cinematic_sequence_device{}
@editable ComboAttackCinema : cinematic_sequence_device = cinematic_sequence_device{}
@editable WalkCinema : cinematic_sequence_device = cinematic_sequence_device{}
@editable BossManip : prop_manipulator_device = prop_manipulator_device{}
@editable Boss : creative_prop = creative_prop{}


OnBegin<override>()<suspends>:void=
    Zonedevice.AgentEntersEvent.Subscribe(OnTriggered)

OnTriggered(Agent: agent):void =
    spawn{FollowPlayer()}

FollowPlayer()<suspends>:void =
    ClosestPlayer := GetPlayspace().GetPlayers()
    

    if (Player := ClosestPlayer[]):

    loop:
        RotateTowardPlayer()
        MoveAnimation()
        WalkCinema.Stop()
        PlayRandomAttack()
        
        
    
PlayRandomAttack()<suspends>:void=
    if (GetRandomInt(0,4) = 0):
        SmashAnimation()
    if (GetRandomInt(0,4) = 1):
        SmashAnimation2()
    if (GetRandomInt(0,4) = 2):
        SmashAnimation3()
    if (GetRandomInt(0,4) = 3):
        SmashAnimation4()
    
    else:
        RotateTowardPlayer()
        ComboAttack()
        RotateTowardPlayer()

SmashAnimation()<suspends>:void=
    GroundAtackCinema.Play()
    Sleep(2.0)

SmashAnimation2()<suspends>:void=
    GroundAtackCinema2.Play()
    Sleep(2.0)

SmashAnimation3()<suspends>:void=
    GroundAtackCinema3.Play()
    Sleep(2.0)

SmashAnimation4()<suspends>:void=
    GroundAtackCinema4.Play()
    Sleep(2.0)

ComboAttack()<suspends>:void=
    ComboAttackCinema.Play()
    Sleep(5.0)


MoveAnimation()<suspends>:void=
    WalkCinema.Play()
    ClosestPlayer := GetPlayspace().GetPlayers()
    if (Player := ClosestPlayer[0], Agent := agent[Player], Fort := Agent.GetFortCharacter[]):
        PlayerTran := Fort.GetTransform()
        Boss.MoveTo(PlayerTran.Translation - vector3{Z:=95.0}, Boss.GetTransform().Rotation, 3.0)
        


RotateTowardPlayer()<suspends>:void=
    ClosestPlayer:[]player = GetPlayspace().GetPlayers()
    if (Player := ClosestPlayer(GetPlayspace().GetPlayers(), Boss), Agent := agent[Player], Fort := 
        Agent.GetFortCharacter[]):



        PropLocation := Boss.GetTransform().Translation
        PlayerLocation := Fort.GetTransform().Translation

        if (LookDirection := (PlayerLocation - PropLocation).MakeUnitVector[]):

            #Z axis
            Yaw := RadiansToDegrees(ArcTan(LookDirection.Y, LookDirection.X)) - 90.0
            #Y axis
            Pitch := 0.0
            #X axis
            Roll := 0.0

            NewRotation := MakeRotationFromYawPitchRollDegrees(Yaw, Pitch, Roll)

            Boss.MoveTo(Boss.GetTransform().Translation, NewRotation, 3.0)

GetClosestPlayer(AllPlayers: []fort_character, Prop : creative_prop): ?fort_character =
    var ClosestPlayer : ?fort_character = false
    var ClosestDistance: float = 1000000000.0 # initialize with a large number
    for (Player : AllPlayers):
        EDistance := Distance(Boss.GetTransform().Translation, Player.GetTransform().Translation)
        if (EDistance < ClosestDistance):
            set ClosestPlayer = option{Player}
            set ClosestDistance = EDistance
    return ClosestPlayer

If I can just get the closest player to work, I have more to add to this

Hey, I feel like you’re just copy pasting without understanding what you’re doing, some lines have 0 sense of what they should do, for example :

FollowPlayer()<suspends>:void =
    ClosestPlayer := GetPlayspace().GetPlayers() # Unused

    if (Player := ClosestPlayer[]): # Calls a <decides> unexistant function

    loop: #Indent is wrong
        RotateTowardPlayer()
        MoveAnimation()
        WalkCinema.Stop()
        PlayRandomAttack()

If you wanna do Verse, and especially 100+ chunks of code, maybe learn a bit more about Verse, practice and don’t ask people to fix your whole code, I’m sorry but I’m not willing to, maybe you’ll find someone who will :man_shrugging:

I am not asking for a fix to whole code. I am asking to understand… The documents are hard to understand. Especially for a first time coder. I work 40+ hrs and have very little time to actually sit down and learn in my free time. I am more of a cg artist, never done code. Never went to school for programing, but want to learn. Just the little comments you just used is what helps me learn a bit. I am sorry if I come off a certain way, like I want someone to write it for me. I am just looking for in depth answers that I can understand. “in terms I can understand” With the little amount of free time i have, it would take months to learn all the specifics of what everything means. By that time people would be leaps and bounds ahead while I am trying to keep up. Do you know what I mean? Again I am sorry if it looks as if I am asking for people are doing the work for me, but that’s not the case by any means.

Just pay somebody to write it then?

I tried that lol

But at the same time I was able to write my own devices for a bosses’ attack that turned out pretty decent, by rearranging code snippets of multiple different types. so I am kinda understanding it a little. Just some things I don’t get I guess.

I understand what you’re saying, but if you really want to learn, you’ll have to take the time to, watch videos, try little scripts first and acquire knowledge with time.

I have the feeling that you went too fast on this script, and it’s a lot for someone here to fix as I told you, maybe paying someone would help, or go watch @GraemeBB tutorials on youtube, he does some beginner level tuts which are good to learn, again I’m not sure of your dev level right now, just assuming :person_shrugging:

I will do that, hopefully no interruptions will ensue lol

And 100% beginner as far as coding so yeah …

Thanks Fenzy.

Maybe start with this one for the basics:

I am actually subscribed to this channel lol.

I have 13 maps published with using devices that are in game (some with verse), so coding wasn’t an issue

Oh yeah I forgot to mention. My fiance is into horses as well. She is an English rider. She thought it was cool you have horse vids as well lol

ah, that’s pretty cool, similar interests :slight_smile:

I have a question, Most tutorials are always about 1 player. Can you direct me to one that deals with multiplayer and how to call on them, or to call on certain ones? I know the player[0-?] and how they are determined. P.S. I have done all the exercises in your back to back video with no issues.

I’m working on a few for the public. Mark does some on his channel that have been out for a while: https://www.youtube.com/@WarforgeXP that might be helpful and those are free. For a paying option (5 bucks a month), I have done and will be doing more on my Patreon page https://www.patreon.com/stablehorsetraining (which is a mix of tech and horses…)