r/badcode • • Sep 09 '21

other language Hey, at least it's in a function…

Post image
519 Upvotes

70 comments sorted by

View all comments

Show parent comment

87

u/GlizdaYT Sep 09 '21

Unreal engine (it's then autocoded to c++)

33

u/[deleted] Sep 09 '21

Are blueprints autocoded? I was sure they were interpreted by a virtual machine.

32

u/srogee Sep 09 '21

Yeah, they run in a virtual machine. You can change a project setting to convert them to C++ when your project is cooked, but in my experience that usually doesn't work with anything but the simplest Blueprints. https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/Blueprints/TechnicalGuide/NativizingBlueprints/

15

u/[deleted] Sep 09 '21

What do you mean by "doesn't work"? Is the translator experimental / unsupported / something else?

3

u/srogee Sep 09 '21

At one point Blueprint nativization was experimental, not sure if it still is. When I last tried it, it crashed when running the packaged game, even when I set it to only convert one Blueprint. It seems very hit or miss whether it will work or not.

3

u/Dmon1Unlimited Sep 09 '21

What is the difference between the two?

21

u/[deleted] Sep 09 '21

Autocoded = translated into C++ and compiled by the C++ compiler into assembly.

Interpreted = the compiled executable contains instructions on how to execute the blueprint and the embedded program, executes it at runtime.

In practice, the main difference is speed. Blueprints are pretty slow (3-4x slower than C++ or so I've heard). For most games this doesn't matter much because games tend to be GPU-constrained.

14

u/gravitas-deficiency Sep 09 '21

Dafuq? I’m all for making programming easier to understand and introduce people to, but this weird visual representation just seems incredibly stupid to me… not to mention, substantially less clear.

20

u/ShapeshifterTrashcan Sep 09 '21

The idea is that you should use both. The complex and modular game mechanics, math, systems are done in code and then you put it all together with scripting, which is then genuinely faster to write, also more flexible, extensible and reusable.

I used to be against visual scripting and thought it's just a crutch for beginners (like e.g. Scratch) because the most elementary things like "sorting enemies based on distance from the player" took ages to create with nodes, using the same approach as in code but across the entire screen, but I was using it incorrectly. You're not supposed to be writing elementary things.

If you have the "backend" of your game done in code, believe me it's then wonderful to just script something like:

  • "Create Quest 'Tutorial'"

    • "Add Objective"
    • "Add Objective"
    • "Add Objective"
    • (add pin)
  • "Assign to: 'Player'"

    • Bind ↔ On Quest Completed event → […]

There, quest done, and you can easily modify it, extend or reuse.

Or design an AI with a behaviour tree, where you put together, nest and reuse certain rules and actions. Or animation graphs with state machines. Writing branching dialogue with a node editor is also wonderful (because writing branching dialogue in a linear fashion – e.g. rows in Excel – will make you wish you were dead when you need to edit or reorder anything).

So basically the way it should be – the mechanics and their intricacies are all coded, now you're just putting the actual content of the game together, using high level of abstraction.

8

u/droomph Sep 09 '21

The caveat being that “low code” environments and products tend to attract the MBA types who think “neat, no need to spend $250,000 for a developer when I can pay $65,000 for a temp” before realizing, oh crap, the reason we pay for developers is to understand how to translate business logic into software in a reusable manner and not because only they know how to wrangle product x and the whole thing explodes. (The MBA, of course, has at this point fucked off months ago to do piles of cocaine at their next victim’s employer’s conference rooms)

I think that’s where most of the animosity comes from.

3

u/SirNuke Sep 09 '21

Or, like everything in Unreal, it's based around the realities of shipping AAA games. One of those realities is AAA games are ~90% art assets. Blueprints enable your artists do wiring logic tasks like making a traffic light change in sync, which frees up your developers to do C++ stuff.

1

u/droomph Sep 10 '21

You didn’t even read my comment. I wasn’t talking about Unreal at all

2

u/SirNuke Sep 10 '21

You are the one posting in a thread about a (bad) Blueprint, and specifically to a lengthy comment explaining how Blueprints are useful. If that's not relevant why post at all? If it is, believe me it's great not getting pestered to wire up opening/closing animations every time a door is added. Visual programming (industry-wise) is used exclusively in the video games, and no one who has interacted with it will have any animosity.

→ More replies (1)

1

u/gravitas-deficiency Sep 09 '21

Lol yeah, pretty much. Over the course of my career, I’ve dealt with at least several dozen “product” people (product managers, program managers, product owners… etc); I’d say about half of them were effectively useless, a quarter of them were worse than useless and actively harmed the development process (either by trying to micromanage implementation or straight up having no idea what they were doing but trying to bluff through it anyways), and maybe 3 or 4 who were genuinely good at their job and meaningfully helped my team actually accomplish shit.

2

u/[deleted] Sep 10 '21 edited Sep 10 '21

I second this. Blueprints are amazing if you know how to use them right, and this is coming from a professional C/C++ backend dev. The secret is to only use blueprint as a “high-level glue”, for connecting your low-level C++ code to the rest of the project which is typically assets (3D models, animations, etc). I can’t emphasize enough how convenient and awesome it is to script the high level behavior of levels and actors with just a few nodes of blueprint.

Unfortunately like with most languages, people tend to overuse blueprints. They are not meant as a substitution for carefully crafted C++ code.

But there are many tasks within unreal (and gamedev in general) for which blueprints are far better suited than any programming language. One example that comes to mind is creating curves (aka timelines) and scheduling events. It is so easy and convenient to edit curves (essentially the dependence of something on time) in the visual editor which is a part of the blueprint editor. You can then pass the time dependent variable from blueprint to C++ and have a smooth animation of some quantity. It would be way harder to achieve this in pure C++ because humans are far better at editing the curve properties in the editor than in picking the right coefficients and putting them into text form

4

u/GlizdaYT Sep 09 '21

I'm with you on that one. I hate programming with blocks but I know a lot of people who prefer visual representation and are used to it so maybe it's just a tool that suits some minds and it's all about it. And maybe for someone who don't like learning syntax

-3

u/gravitas-deficiency Sep 09 '21

A few people might prefer it, but I guarantee you that nobody else on the team they’re working with likes it. This sort of programming tool is objectively bad, and abstracts away far too much of the intricacies of programming that are absolutely crucial for a good developer to understand.

Put another way: this is a tool designed to let non-programmers write code. That is not a good thing, nor is it actually coding, in much the same way that plugging a few options into NVidia Canvas doesn’t make you a skilled artist/painter.

4

u/prelic Sep 09 '21

It's not objectively bad. Some would argue that those abstractions are a benefit, not a disadvantage. Like any other tech tool since the beginning of time, it has a time and a place. For general purpose programming I would have a hard time with this, but we do some visual style programming similar to this in my company where we simulate complicated aviation systems, and stuff like this is great for doing that. It's very easy to create and visualize a bunch of sensors and control boxes, and the way they interact with each other.

Like every tool, ever, it can be used to benefit, or misused. Tools are rarely "objectively and completely" bad.

3

u/SirNuke Sep 09 '21

It's really not for you, more for non-programmers to handle little wiring tasks. Though Unreal Engine's C++ environment is painful enough that you might still want to use Blueprints when you can.

They do get abused, but the gaming industry isn't known for producing good code anyway.

3

u/gravitas-deficiency Sep 10 '21

Oh.. oh god. My eyes.

3

u/dyingpie1 Sep 09 '21 edited Sep 09 '21

Makes sense. Looks like unity but it’s not.

12

u/Stryker77 Sep 09 '21

I’m pretty sure unreal came first with visual scripting

6

u/ShapeshifterTrashcan Sep 09 '21

Grail: Hold my nodes…!

4

u/[deleted] Sep 09 '21

Let's not forget Blender's "node-based everything"