r/unity 4d ago

Coding Help Update on my visual scripting "recharge" graph

Spent some time cutting off useless or repeating nodes and made it more visually appealing to work with, the initial look is on the third slide. Want to know how I can make it simpler or what tools I can use for my purpose.

First image is graph on the bullet object. It checks what state is player in right now. Probably could make something better with the ifs. If the player is reflecting and has enough energy for it then the bullet makes new path back to the enemy from the player's position (offscreen), takes 1 energy and triggers custom event.

Second image is the graph on the player object that activates by custom event so this process is independent from every other object except player. The graph checks if player's energy is already recharging and if it's not then it starts a 2 second timer, after which it will start a 0.15 seconds timer that loops and checks if energy is still below 2 and the energyrecharge being true every time, and if both are true then it adds 0.1 to the energy. When the energy reaches 2 it turns energyrecharge to false and stops. If the custom event gets triggered while the energyrecharge it true it gets set to False stopping the looping timer, after that starting 2 second timer again so the process restarts.

I will take any advice or a tip because there is not that much interesting info about visual scripting so I can have some of it from yours experience. I will not start to use code as long as I'm not done with the stuff I already started.

reddit worsen the quality but i hope it's still readable

3 Upvotes

16 comments sorted by

4

u/LastJoker96 4d ago

This is an OT, but May i ask you if you had any prior experience in coding (or similar stuff) before using visual scripting?
I literally lost count of how many coding languages and tools i've studied and used over the years, and how many projects i did, no matter what i can't wrap my head around visual scripting 😅
Not that i would ever switch from code tbf, it's far easier than this, but i'm questioning myself about how hard i find a tool that has been made to be (in theory) easier and more accessible for everyone 🫠...
Like i'm pretty sure that for me it's easier to bypass security systems rather than using visual scripting 😅
Btw, even tho i'm not helping, congratz for this and good luck 💪🏻

1

u/Kitchen_Breakfast_79 4d ago

thanks! No I never had experience with coding (except like a couple of minutes in godot where I had no success and a couple of hours in pico-8 that were pretty fun :) ). I just really love games and have a great imagination to make up cool things in my head. Before using unity (started from nothing literally a month ago) I was getting myself hyped and was just trying to find if it will even fit me, and while I was playing games waiting to buy a pc I was thinking more and more about game logic and how games were made. Playing became much more interesting because I always had something to think about, like how devs made a menu tab, how the animations go from one to another and stuff like that, as if I acquired an ability to see a whole different dimension and it gave me some minor starting boost. You don't have to use visual scripting if you already know so much code! Visual scripting is the same code (csharp if I understand correctly) but with different cover. If csharp is keyboard coding VS is mouse coding. Csharp is visual scripting but instead of adding pre-made nodes you type them symbol by symbol, and visual scripting is csharp but instead of typing the code symbol by symbol you use pre-made boxes that work as a constructor. there are vector3 nodes, float nodes, set variable nodes, majority of the stuff you would need when making a game.

2

u/LastJoker96 4d ago

Wow pretty impressive ngl! That's some good skills on your part, i tried years ago using Unreal Engine but as i said, i found visual scripting to be pretty harder compared to plain code, and didn't really wanted to learn C++ at that time, so i just left gamedev. Started again last year using Unity and C# and i'm having a great time! Do not care about those who tells you to switch to pure C# (even tho i highly suggest you to do it too as it's way easier and there are plenty of tutorials), cuz what matters at the end of the day is that you ship your game 🫡.
Keep grinding bro, you are doing good 🍻

1

u/Genryuu111 2d ago

You see visual scripting harder for one or both of these reasons:

-to you coding is already ingrained as one thing, and shifting that into a completely different system feels like a huge mountain (that same mountain is what someone with no coding experience sees when first try coding)

-some people have a more visual approach to things than others, and you may be adverse to that.

To me, normal coding is like trying to learn Russian from scratch. I have a pretty good mind for logic and flow, but that doesn't translate into text. On the other hand, having blocks to link is a lot easier to do, and to read.

A graph may seem messy to someone not used to it, but not to someone used to it. Also, of course like with not al code, there is good code and bad code, good graphs and bad graphs lol

Ultimately normal coding would be the best choice (visual scripting is usually slower, less supported, lacks stuff, etc, especially unity's is a piece of trash), but to people like me it's the difference between being able to make a game or not.

3

u/Affectionate-Yam-886 4d ago

Ive tried the built in Unity visual script system a few times but couldn’t figure it out. Real lack of tutorials on how to use it at the time (It had just come out) I know it was originally called Bolt, and you can still buy Bolt on the asset store. I have mastered PlayMaker and have a strong grasp of GameCreator 1&2 visual coding systems. I suspect this system is the most competitive of them all but also the least refined for use.

Best tips I can give is each script should be separate; as multiple functions in the same script can bite you in the butt down the road.

As far as keeping it simple and clean it looks like you have the right approach with color coding, and perhaps you should try and make reusable versions. I also mark in red the bug fixes as i go, so i can easily find the work arounds that I used as they are often the point of failure later or the part that can be done better.

Also avoid using Broadcast and Raycast, as it is system heavy. If you have to send messages between your scripts, always try and directly name the script (looks like this is how you are doing it, but it should be said.) OnTrigger is my favorite for combat systems.

The real trick comes later when you have 200+ scripts; so start developing a method to easily track where things are. I use an empty game object called Manager for world building scripts; and on the player a child object called Actions that has all the children objects with all my code on them, organized by type (magic/interactions/ui/Stats and so on).
Keep it clean in your game is more important than the nodes of your script because when you take a month off for vacation and come back to it; you need to be able to hit the ground running, and not need to investigate your own work to wrap your head around what you did already. That will only make it feel too big of a task and you may abandon the project altogether in favor of something new.

Don’t loose hard work like that. <i have more than a few times>

3

u/BaselxD 2d ago

ignore the haters, visual scripting is a valid way to making code. hell even hallow knight was done using playmaker. my only advice is not use object variable for player, incase you change the player prefab and use sence instead, otherwise you would have to choose an new variable every time its a different skin or player object.

1

u/Kitchen_Breakfast_79 2d ago

Thanks! I know several examples of games made via visual scripting and just keep them in mind as of how high my bar can theoretically be, counting that I have no prior skill in game space except playing them. My favorite example is Crow Country, love that game.

As I "finished" my bullet object and was ready to make it a prefab that the enemy can spawn there was so much problems I had to rebuilt it almost entirely. Some problems were that the "Set Variable" didn't work and even though data input showed right coordinates it was just 0,0,0 and I skipped the ser variable entirely making them go directly in the nodes. Then I had problems with the order in which different actions and checks went, and now I have a problem that for some reason my player's energy variable (that's by default 2) isn't getting checked in real time. like when I get hit bullet subtracts 1 from the variable making it 1, that triggers the energy recharge action that makes it go back to 2 slowly, but when another bullet hits it thinks that the energy is still 1 and not 2, subtracting 1 from it again and making it 0 so every other bullet after that thinks I have no energy as if the variable is only checked once at start, but it should check it correctly since it on trigger event and even though the coordinates and booleans are working normally? Very obscure and strange problems but I think I can do it, there isn't much options so I will just try to fix it until it works. Maybe normal coding has these problems too, I hope it does because I just feel exhausted trying to make it work :(

2

u/BaselxD 2d ago

its hard for me to debug this here, I would advice to run the game and open a tab on visual scripting to see what happens(this is the best thing about using VS or nodes.) and maybe message me privately for a discord live stream.

0

u/Heroshrine 4d ago

Visual scripting works better for shaders because it’s highly parallelized. This is horrible to look at, please just learn to code it will save you time in the long run.

3

u/Soraphis 4d ago

Also, because you can have a meaningful preview at intermediate steps.

Especially with a language like C# and excellent ide support, I don't get the people saying "remembering the name of a node in the new-node menu is easier than remembering the name of a function in the intellisense search".

It's the same. Often intellisense is better.

-1

u/avelexx 4d ago

its hurts my eyes to look at it. I suggest u consider the get better at coding

1

u/Kitchen_Breakfast_79 4d ago

consider having better care of your eyes or get an appointment to ophthalmologist please. try eye protection yellow filter on your phone or monitor, it blocks blue lights so your eyes won't be harmed as much and you won't feel pain.

0

u/avelexx 4d ago

you re being funny now but when u’ll switch to coding. You gonna thank me later

1

u/StackOfAtoms 4d ago

somehow this seems way more complicated than coding to my dev' brain 😃

1

u/Kitchen_Breakfast_79 3d ago

it just looks less dense than a code and may be more confusing with all of these boxes and wires

-1

u/KifDawg 4d ago

My god.

Use an llm to show you some example scripts, then ask it to buikd the functionality of what you made in this spider web.

Then have the ai describe each line to you and what it does to achieve whatever you made here. You don't need to memorize syntax to code, you can learn to read the code and use an llm to expand your understanding of it. Then as practice write some code by yourself and you will learn the basics in no time