Download

Magic Nodes

Think of pointers as a box that contains a number;
This box is a value, contains something inside:

ACharacter* MyCharacterA // ← there’s a number in there: 14687354
ACharacter* MyCharacterB // ← there’s a number in there: 86587531

The number inside the box is the address of the thing that pointer is pointing to, in this case a ACharacter entity. The address number in the box is where that character lives in the RAM of your computer.


A reference is a label you give the actual ACharacter, or to that box with the address of the ACharacter.
When you access a label, a reference, you are telling C++ compiler to use the object you named that label. The compiler just picks the box and use it…

When you access a box, a pointer, the compiler will pick the box, read the number inside, then it will go all the way to your RAM and finally access the ACharacter living in that address.

You can have several boxes, containing the address of another box, with the address of another box, and so on… Up to the box which finally contains the address of the ACharacter entity.
Your program will visit and open each box until it goes to the one that gives the address of that entity.


But references contain no value. They just give identity to something that actually exist.
Because they hold no value, Unreal Build Tool assume that you want an output pin that is accessing something “named” that label.

You can also give a label to a pointer, not just objects, so:

ACharacter* & _Character; // ← there’s no number, no address, this is not a box.

Above, you have the obligation to tell the compiler what is the object that label is representing.
That is something of type ACharacter* you gave this label while in the body of this function.
The actual ACharacter* is found outside the function. You can’t change the label you gave the box.


const ACharacter* & _Character; // ← same as above!

But here, you promise that you won’t change what is inside the box, once the label is attached to a valid box, a pointer. You also can’t change the label you gave the box, not only that, you cannot change the address number inside the box either.

Unreal Build Tool assume that you want to use this label as an input.
But it is going to scream at you if you never give a box for this label to be slapped onto, while in the body of the function. Because labels have no value… Unreal is going to tell you:

The current value of the '_Character ' pin is invalid: Reference inputs must have an input wired into them.

Let’s say you used MyCharacterA as input, _Character is now its local label…
Now let’s say you’re done with MyCharacterA and want work on MyCharacterB.

You do:

_Character = MyCharacterB;

But you get an error because you’ve promised you would not change the number inside MyCharacterA box. For the compiler, _Character is simply another name for MyCharacterA.

UPARAM(ref) tells Unreal that you want a label as input, but you will not promise that you will never change the number address in the actual box or the state of MyCharacterA.

Thank you for such a detailed answer. I think that now I know enough to be dangerous :upside_down_face:

I’ll practice for a bit using your example code as a guide. I don’t suppose the C# version of the plugin will be ready anytime soon… :wink:

Awesome support, btw

It’s really hard to make all the things I want to do with only Slate + Mono.API.

So I started to implement a SLN Generator for Visual Studio Code, which is very light weight external editor and is supported by Omnisharp servers of C# analysis.

In case VS Code is installed, we can launch the external solution for deeper C# analysis than what I have in-editor (I have no MSBuild running with Unreal Editor, but VS Code does).

MSBuild can scan scripts, and also can actually scan any referenced DLL and their types.

The best thing is reference counting!
Here it detects that I am no longer using ‘state’ anywhere anymore:

Heh… figured out how to add custom filter categories to asset browser.
Also got importing of C# scripts from drag & drop working:



Implemented a basic “Diff” tool and added a few more toolbar actions for launching on Visual Studio, in case built-in code editor or VS Code are not enough :sweat_smile:

So, I have ported this plugin to Unreal 5. Works fine, the C++ engine adapted well to UE5.
However, the C# architecture that I have built for this plugin, there’s some serious blocking changes in the core of Unreal 5 that makes it impossible for me to compile C# DLLs within the Unreal Editor now…

I suspect I will be forced to drop the C# project and wait for Verse scripting, I have done all I could with the C# VM, but it just won’t load any CS DLLs anymore on Unreal 5, and blocks the Editor from launching which is a no no no.

So for now, I move on and keep support for the C++ node only.

1 Like

Hello,
I tried adding your plugin to my project, but failed.
I created a new blank cpp project, added the plugin, then created a blueprint and added a magic node with one of your presets. This is the error I get when I try to compile:

Parsing headers for MyProject2Editor
Running UnrealHeaderTool “C:\Users\Dev\Documents\Unreal Projects\MyProject2\MyProject2.uproject” “C:\Users\Dev\Documents\Unreal Projects\MyProject2\Intermediate\Build\Win64\MyProject2Editor\Development\MyProject2Editor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog=“C:\Users\Dev\AppData\Local\UnrealBuildTool\Log_UHT.txt” -installed
Reflection code generated for MyProject2Editor in 3.0091589 seconds
Building MyProject2Editor…
Using Visual Studio 2019 14.28.29336 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 9 actions with 16 processes…
[1/9] MGC_StringArraySorting__CPP.cpp
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2\MagicNodes\MGC_StringArraySorting__CPP.h(17): fatal error C1083: Cannot open include file: ‘MagicNodeRuntime.h’: No such file or directory
[2/9] MGC_StringArraySorting_B__CPP.cpp
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2\MagicNodes\MGC_StringArraySorting_B__CPP.h(17): fatal error C1083: Cannot open include file: ‘MagicNodeRuntime.h’: No such file or directory
[3/9] MGC_StringArraySorting_B__CPP.gen.cpp
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2/MagicNodes/MGC_StringArraySorting_B__CPP.h(17): fatal error C1083: Cannot open include file: ‘MagicNodeRuntime.h’: No such file or directory
[4/9] MGC_StringArraySorting__CPP.gen.cpp
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2/MagicNodes/MGC_StringArraySorting__CPP.h(17): fatal error C1083: Cannot open include file: ‘MagicNodeRuntime.h’: No such file or directory
[5/9] MGC_Awake_Start_Update_Stop__CPP.gen.cpp
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2/MagicNodes/MGC_Awake_Start_Update_Stop__CPP.h(17): fatal error C1083: Cannot open include file: ‘MagicNodeRuntime.h’: No such file or directory
[6/9] MGC_Awake_Start_Update_Stop__CPP.cpp
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2\MagicNodes\MGC_Awake_Start_Update_Stop__CPP.h(17): fatal error C1083: Cannot open include file: ‘MagicNodeRuntime.h’: No such file or directory

What am I missing ? Sorry I’m kind of new to this.
Thanks

Edit: I’m using 4.26

You have to add the runtime module to your project’s Build.cs file.
If you don’t add the module dependency then your game module can’t find the classes:

Well now that is what I get when compiling… Sorry if this is supposed to be obvious:/

Invalidating makefile for MyProject2Editor (MyProject2.Build.cs modified)
Parsing headers for MyProject2Editor
Running UnrealHeaderTool “C:\Users\Dev\Documents\Unreal Projects\MyProject2\MyProject2.uproject” “C:\Users\Dev\Documents\Unreal Projects\MyProject2\Intermediate\Build\Win64\MyProject2Editor\Development\MyProject2Editor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog=“C:\Users\Dev\AppData\Local\UnrealBuildTool\Log_UHT.txt” -installed
Reflection code generated for MyProject2Editor in 3.2025089 seconds
Building MyProject2Editor…
Using Visual Studio 2019 14.28.29336 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 13 actions with 16 processes…
[1/13] MyProject2.cpp
[2/13] MyProject2.init.gen.cpp
[3/13] MyProject2GameModeBase.cpp
[4/13] MyProject2GameModeBase.gen.cpp
[5/13] MGC_Awake_Start_Update_Stop__CPP.cpp
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2\MagicNodes\MGC_Awake_Start_Update_Stop__CPP.cpp(25) : error C2275: ‘UMGC_Awake_Start_Update_Stop__CPP’: illegal use of this type as an expression
C:\Users\Dev\Documents\Unreal Projects\MyProject2\Source\MyProject2\MagicNodes\MGC_Awake_Start_Update_Stop__CPP.cpp(25) : error C3861: ‘Subscribe’: identifier not found
[6/13] MGC_Awake_Start_Update_Stop__CPP.gen.cpp
[7/13] MGC_StringArraySorting__CPP.gen.cpp
[8/13] MGC_StringArraySorting_B__CPP.gen.cpp
[9/13] MGC_StringArraySorting_B__CPP.cpp
[10/13] MGC_StringArraySorting__CPP.cpp

The “Subscribe(…)” macro have been changed to “Enroll(…)”

That’s what your copy of these files are complaining about.
I think you have outdated assets in \Plugins\MagicNode\Content\Examples.

I downloaded everything from the marketplace yesterday though. Should I get these from your git ? I was interested in the alphabetical sorting node.

You can just delete the “MGC_Awake_Start_Update_Stop” source files and the node from that Examples folder I posted above. Then compilation should just work.

I don’t know why that is outdated on Marketplace, I have updated everything before submitting to Epic the latest version.

Thanks a lot for your help. I will try this in a few days when I get back to my computer, but that should fix things!

If you plan to stop development on the C# version, would you consider releasing it on Github for use “as is”? I expect to be using 4.26 for quite some time, and I don’t need to do anything complex with it.