I want to use the JumpedEvent found in the Fortnite Digest but I cannot seem to figure out how to properly use it to subscribe a player that jumps. Has anyone used this command that has an example of it being used? https://i.imgur.com/HRMyYzI.png
Does this help?
CheckPlayerJumpedDevice := class(creative_device):
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void = {
Players:[]player := Self.GetPlayspace().GetPlayers()
for (Char -> Index : Players) {
if (FortChar := Players[Char].GetFortCharacter[]) {
FortChar.JumpedEvent().Subscribe(HandlePlayerJump)
}
}
}
HandlePlayerJump():void= {
Print("Player Jumped")
}
It works! https://i.imgur.com/DqppmTC.jpeg Thank you so much!
Side question. why do you use the {} brackets to indent the code? I had never used them before so I wasn’t sure if they were needed to make everything work.
why do you use the {} brackets to indent the code? I had never used them before so I wasn’t sure if they were needed to make everything work.
The Verse parser accepts both curly braces ({}
) and whitespace as forms of indentation in most cases. The current idiomatic style is to prefer whitespace for code blocks, and to use spaces (no tabs) for indentation.
super basic question, but do you always need to use OnBegin at the beginning of a new device or can you use a different command to start this later in the game?
Hi @TheAweDam:
You do not need to use OnBegin
for every creative_device
you make, no, but you usually would since that’s where you would run any logic right when the game begins.
Could you elaborate on what you mean by “start this later in the game” and what you are hoping to achieve?
Currently, the only exposed virtual methods on creative_device
are:
creative_device<native><public> := class<concrete>(positional):
# Called when the game experience begins
OnBegin<public>()<suspends>:void = external {}
# Called when the game experience ends. Note that any coroutines spawned inside OnEnd may never execute.
OnEnd<native_callable><public>():void = external {}
# Get the transform of the object with units of cm.
GetTransform<override><native>()<transacts>:transform
Ah okay, yeah just wasn’t sure why I always see that being put in at the front of stuff. No specific use cases right now, just curious really. Very new to the coding side of stuff and dont really have a clear starting point
Hey apparently you now need to add an argument for this to work, will just leave this here for anyone who faces the same issue as me
HandlePlayerJump(thing:fort_character):void= {
Print("Player Jumped")
}
hey I was wondering the same thing about tracking if a player jumped from a separate function. Like let’s say I want to check for a Character jumping during a loop inside a separate function.
how could we do that?
You can save the jumping state of all players inside a [player]logic
map{}
, you’ll have to check for when the player lands though
Hey thanks for this suggestion. Unfortunately I’m not so great with all this yet.
Are you able to show any example code using your method? (Just the player logic map portion)