Basic Admin/Debug Privileges

Hello. I am not a total noob when it comes to visual scripting, but I am still learning Blueprints. However, I am a sharer, and thought I would share this little script I made with anyone who may find it useful.

This blueprint script could be used to allow secret abliities, cheats, or in my case, additional power while testing my game.

It is fairly straight-forward, so lets begin!

First you want to start by creating a set of Boolean Variables.
Boolean Variables are variables that can contain one of two states, and can be seen as 0 & 1, True & False, or On & Off. This makes them great for binary options, basic randomization, and in this case, Switches.

1 - Make Variables For Keypresses Admin Privelages.PNG

The variables I have created are:

  1. ‘isAdmin’ - a basic switch that will be toggled upon a set of key presses, allowing extra abilities in-game\
  2. ‘0/1’ - a switch for simple randomization (these can be used for npc’s to speak without saying the same thing over and over.
  3. ‘A’ - a switch to be triggered while the “A” key is pressed
  4. ‘D’ - a switch to be triggered while the “D” key is pressed
  5. ‘M’ - a switch to be triggered while the “M” key is pressed

Next, you will make the key presses you chose to activate their ‘switch’.

1 - Make Variables For Keypresses Admin Privelages.PNG

When they are pressed, they will turn their respective switches on, but upon release, they will turn the switch back off.

Next up comes the part where the game determines if all 3 keys are pressed at once. The Get nodes on the left are the switches themselves. If they are on (the key is pressed), they make their ‘condition’ true.

Look at the Branch node checking to see if ‘M’ is pressed. Upon pressing ‘M’, the branch also checks if both ‘A’ and D’ are pressed as well.
If you press ‘D’, it checks for ‘A’ and ‘M’, and if you press ‘A’, it checks for ‘D’ and ‘M’. None of the branches on the left will continue any further unless ALL 3 keys are pressed down at the same time.

When they are, however, it will go on to the next node, checking if you already have ‘isAdmin’ on. If not, it turns it on and then displays a message. If it is on already, it turns it off and displays a different message.

Now that there is a way to toggle on and off the administrator privileges, it’s time to test out the functionality.

I have added 2 branches off of the keypress I decided on for this next part, which is the ‘R’ key. I did this because I wanted it to run the code as soon as I press the ‘R’ key if the privileges are enabled, but if not I didn’t want the ‘function locked’ text showing up until the ‘R’ key was released.

If you press ‘R’, it checks to see if ‘isAdmin’ is enabled. This little snippet of code could be saved as a function and reused for many applications so as to not clutter the blueprint space. To do this, just highlight the ‘Get’ node for ‘isAdmin’ and the Branch node that is checking it.

Right-click, and select ‘collapse to function’. From here you should rename the function on the left side of the screen. It is NORMAL for it to show an error on the node FOR NOW. I have set up the Function to use the T key and run a basic text log to show that it works.

Open it by double-clicking on it.

ALT + Click on the False node to unlink it.

Click Compile and Save to remove the Error, and test it out in-game.

Let me know what you think. Will this be useful to you? If so, feel free to share your uses in the comments.

Thanks for reading!

Thanks, i will check it out.

Please do, let me know if you have any issues / what you think.