Blinking Player Visibility On Damage
To achieve the flickering visual effect on the Infiltrators, you're going to repeatedly hide and show each player's character. You want this to occur in a function whenever an Infiltrator gets damaged, but you also need to make sure that the rest of your code keeps running when this function is called. This gets even more complicated in situations where you have multiple Infiltrators. There might be multiple Infiltrators damaged at the same time during a game, so you'll need code that can handle each of them individually.
To achieve this, you're going to make heavy use of the spawn expression. Spawning a function allows you to run it asynchronously, without putting the rest of your code on hold. By spawning a function for each Infiltrator, you can ensure that each Infiltrator's flickering happens independently of the rest.
Follow these steps to learn how to flicker each Infiltrator's character when they receive damage.
Creating the Flicker Loop
- Add a new function
FlickerCharacter()to theinvisibility_managerclass definition. This function takes afort_characterand flickers their character in and out of visibility. Add the<suspends>specifier to this function to allow it to run asynchronously.# Flickers an agent's visibility by repeatedly hiding and showing their fort_character FlickerCharacter(InCharacter:fort_character)<suspends>:void= Logger.Print("FlickerCharacter() invoked") - Within
FlickerCharacter(), loopHide()on theInCharacter,Sleep()for a certain amount of time (theFlickerRateSecondsyou defined earlier),Show()the character, and sleep again. This will create a flickering effect on the character that allows enemy players to track them but still have some difficulty aiming due to the brief periods of invisibility.
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.