Download

Help I'm So Messy (Organization)

So I started using UE4 about half a year ago and I’ve bee learning primarily through experimentation. Here’s my game so far: https://twitter.com/qdeanc/status/729787356551610368

The problem is that I’m also super messy: Screenshot - 608ce4a6b5a093ef53a915e26d396444 - Gyazo

Can someone give me some tips on how to get organized? So many of my variables are scattered around and referenced that I ended up putting all of my programming in one Blueprint.

I’m also new to UE4, but as a programmer I can tell you that making functions helps a lot: for exaple if you have a part of code that makes you character move, make a function. If you have to check some numbers to see if you can do an action, make another function. If you need your character to take damage, you guessed it, make another one and so on. If you need to use timers that just make a macro instead beacause you can’t put timers into functions if I’m not wrong.
I also see a lots of wires going all the way across you screen. You shouldn’t to that, you are just making everything confusing. Just store the information you need in a variable so you can get it and place the node close to where you need the data to be, and if you are making a function you can make local variables so you don’t get hundreds of variables in places where you won’t need them.
Now for the references: I have no idea about what’s the best way to do it (as i said i’m new to UE4), but I usually make a reference to my GameState blueprint in the event “begin play” of every actor, and in there I store every important reference or data, so if some other blueprint needs them I know I’ve stored it there and i can easilly get it. You can also expose variables on spawn so the creator can pass data to the created blueprint immediately.
I hope I helped a bit (and I also hope i didn’t mess my english up to much, if so, sorry about that, I tried to be as clear as possible :b )
Also I like your game, it’s looks neat! :smiley:

TL;DR: functions + local variables + storing data in the GameState blueprint so every blueprint can easilly acces them = less messy blueprints :smiley:

Thanks!

Unfortunately, setting variables requires an event tick; something I find really annoying to duplicate. I have this long line of custom events connected to the event tick so that I can set variables and it’s incredibly annoying:

Any ideas on how I can make this easier?

OOP (Object Oriented Programming) has a fundamental basis in Game Development since games generally always deal in Objects.

Objects have properties (variables for example) and purpose that are only relevant to themselves. With that said ive always gone by the notion that “Objects should manage themselves”. This is an important concept to understand when dealing with Objects, especially when you realize that High Cohesion and Low Coupling (another fundamental concept in programming, especially with OOP) also guides you when it comes to not only Code (or BP) cleanliness and readability but also its performance efficiency and its ability to be extended when necessary.

Id be interested to see how your Project files are laid out as well. A Clean and organized project that has obvious structure generally will also help you foster good management of Code (or BP) structure as well.

Maintaining a good standard is difficult but will help you to no end further into the future. I recommend you google such a topic or better yet, take a look at some of the Sample projects that you can download for free on the Marketplace and see how they manage their file and Code (or BP) structure.

For example,

Generally if you find a piece of Code you are copy and pasting all over the place, you should make it a function.
Your variables should all follow the same naming style, as well as your functions and assets.
Especially for Blueprints i like to make sure that the Execution Path (white lines) are straight as is practical.

Also, as for you can “only set variables on Tick” this is incorrect, variables can be set anywhere if that SetNode receives execution.

Try thinking more about where is it appropriate to hold information and also how you intend to access and modify it.

If you need for example an event tick multiple times I suggest you create a sequence and then attach custom events to it that way you can just call that custom event which acts like an event tick where you need it.

Also creating functions helps a lot with this problem.

Wow! This Blueprint is extremely shocking! I can’t imagine that you are able to make some specific changes within a few seconds if you need to. My tip would be to create small functions that are as generic as possible. Then you can create other functions in which you call the small function chunks. If you need to change something, you can simply rework one of the smaller functions and every other function that includes this specific function, will be updated as well.

And another thing: Name your variables properly and group them! This is very helpful :slight_smile:

Daniel

I love it!!! :smiley: modern art!! I wanna a t-shirt!!

btw I think that this can be useful for you
how-to-use-delta-time
https://answers.unrealengine.com/questions/38798/how-to-use-delta-time.html

Ok, so I need to break it up into functions and learn from example blueprints. Thanks!

I’m still unhappy about setting variables, though. I often need variables to update every tick; I don’t want to have to keep duplicating event ticks with custom events, but it seems like there’s no other way.