Hi,
Do you know how to optimize it ? Because I’ve no idea how, it’s just a real spaghetti code right now
Hi,
Do you know how to optimize it ? Because I’ve no idea how, it’s just a real spaghetti code right now
I think it really helps if you think of blueprint scripting as similar to writing, with its own grammar, gaps between words & paragraphs, different sections grouped under headings, etc. Everyone has their own style, but here are a few things that might help you out.
Add some distance between individual nodes. Think of it as the spacing between words when we write or type out a sentence.
Instead of drawing out several wires from the same variable node (for example, max walk speed in the image), use different instances of the variable if they’re going criss-cross. Imagine trying to draw a connection from an earlier word in a paragraph just because it repeats after a few lines. Soon things will start looking messy with wires all over the place.
Plus if you leave enough gaps between nodes using step 1, you will have space for those extra variable nodes.
Try to keep the flow going in one direction. For example, those four branch nodes at the bottom right going in the reverse direction to reach the next step. Instead, maybe move those add movement nodes to the right and you can see the flow happening from left to right just as soon you open the blueprint. This will become more noticeable once you have very large BP graphs.
Use Functions/Events for repeatable code. For example, you can use a function for setting the MaxWalkSpeed. It can have an input for how much it should change (+5/-5 in your case). Inside the function, the character movement component will take the input and add it to the max walk speed. And now you have essentially consolidated all of those nodes within a single node.
Ok thank you, I will try that later
the bottom right sequence into four branches could just be a switchOnEnum set to use the same enumerator. Changes 13 nodes into one.