Quantcast
Channel: General - Epic Developer Community Forums
Viewing all articles
Browse latest Browse all 9940

Verse Beginner, Need Help with Simple Problem

$
0
0

This’ll probably be light work for those of you guys with pretty much any experience with verse, but I’m still learning so I’m struggling with this.

I’m trying to make a player that falls under a certain class (and triggers a switch to be on) to be eligible for the ability to crouch to double their health. Uncrouching returns it back to default.

I got this to work without the switch logic, but I don’t want every player in the lobby to have this feature. How do I add an if statement that checks for the switch to be on and subscribes the crouch ability to the instigating player?

using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters}
using { /Fortnite.com/UI}
using { /Verse.org/Colors}
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }

HealthCrouch := class(creative_device):

    #wip, broken - currently no check for switch device, idk how to program this
    
    @editable
    Switch : switch_device = switch_device{}

    CrouchEvent(FortniteCharacter : fort_character, IsCrouched : logic) : void=
        if (IsCrouched?): 
            #crouch adds double health
            FortniteCharacter.SetMaxHealth(160.0)
            FortniteCharacter.SetMaxShield(200.0)
        else:
            #uncrouch removes double health
            FortniteCharacter.SetMaxHealth(80.0)
            FortniteCharacter.SetMaxShield(100.0)

    #pretty sure this is unused
    SpawnEvent( Agent : agent) : void =
        if (FortCharacter := Agent.GetFortCharacter[]):
            FortCharacter.CrouchedEvent().Subscribe(CrouchEvent)

    OnBegin<override>()<suspends>:void=
        for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[], Agent := agent):
            Sleep(1.0)
            #i need an if statement that subscribes to CrouchEvent if the switch is toggled on but i'm still struggling to implement
            #if (Switch := Switch.IfOnWhenCheckedEvent(FortCharacter)):
                #FortCharacter.CrouchedEvent().Subscribe(CrouchEvent)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 9940

Trending Articles