I need help. How to call a Visual Effect Powerup Device in my Verse code to a specific player?

I’m building a map where there is a freeze gun (this part of the code is already working) that freezes the player who takes damage from a specific weapon. The problem is: I wanted the player who is frozen to have a block of ice on his body. The way I thought of doing this was using a Visual Effect Powerup Device with a custom niagara effect (a custom 3d mesh). The duration of the effect would be simple to resolve by simply syncing it with the duration of the freeze.

But I don’t know how to trigger this Visual Effect Powerup Device specifically on the player that is frozen. If not directly, perhaps with an intermediary trigger or switch. But I’m still too new to Verse to know how to do this. Can anyone please help me?

Here is the code so far for my freeze gun:

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


freeze_device := class(creative_device):

    @editable ConditionalButton : conditional_button_device = conditional_button_device{}
    @editable FreezeTime : float = 1.5
    

    OnPlayerDamage(DamageResult : damage_result) : void =
        if:
            Instigator := DamageResult.Instigator?
            Agent := Instigator.GetInstigatorAgent[]
            ConditionalButton.IsHoldingItem[Agent]
            Target := fort_character[DamageResult.Target]
            
        then:
            spawn:
                FreezePlayer(Target)

    FreezePlayer(Target : fort_character)<suspends> : void =
        Target.PutInStasis(stasis_args{})
        Print("frozen")
         

        Sleep(FreezeTime)
        Target.ReleaseFromStasis()

    OnPlayerAdded(Player : player) : void = 
        if (FortCharacter := Player.GetFortCharacter[]):
            FortCharacter.DamagedEvent().Subscribe(OnPlayerDamage)
   
    OnBegin<override>()<suspends>:void=
        GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)

       for (Player : GetPlayspace().GetPlayers(), FortCharacter := Player.GetFortCharacter[]):
            FortCharacter.DamagedEvent().Subscribe(OnPlayerDamage)

You can use the “Pickup” function of the visual effect powerup device, passing the target agent as the parameter. You should also set the “Apply To” option on the device to “Player” so it only applies to your target.

Add an editable Visual Effect powerup device:

  @editable
  FreezeVFX : visual_effect_powerup_device = visual_effect_powerup_device {}

then in FreezePlayer() add:

  # Get the agent from the target fort_character
  if(Agent := Target.GetAgent[]):

      # Apply the freeze VFX
      FreezeVFX.Pickup(Agent)

I would recommend utilizing the Fortnite.Digest.Verse file in the vscode folder explorer to look for specific functions like this. Many will have comments explaining how to use them.

1 Like

It worked!! Thank you for the help and the advice, bro

1 Like

Is there a way to remove the VFX from just a specific player? It seems there isn’t a function for it.

Yes. Create a second powerup device with the same exclusivity index and an empty custom effect, turn on the “Disables effect on pickup” option, and use .Pickup(Agent) on this device to turn off the original.

1 Like

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