Hello,
Is there a way I can call a C++ function through blueprints? I am an artist/developer making a blueprint-only game.
I use mesh distance fields for a couple things, namely DFAO and some water shaders. I occasionally shift the world origin through blueprints, and when I do the distance fields don’t receive the offset. In the image below it looks like there is a simple function that could be called at the same time I shift the world origin, but I don’t know if this is possible to do in blueprints.
Any advice is appreciated, thanks.
Hi, I was just looking at that as well. It does also require a C++ project. In that case I think it makes sense just to get a programmer to help me write the function and expose it for use in blueprints.
I’ll have to see if it’s possible to convert a project, or if I would need to make a fresh one and then migrate things over. That’s probably something easy to google though.
Thanks NachoMonkey!
Yeah I just skimmed instructions for conversion and it seems simple. I am gonna take a break for rest of day but give this a go tomorrow. Once ready to write that function I will give you a shout, I really appreciate that!
Thinking a little further in advance, I am assuming it is just as simple as when I shift the origin, also call this function and that is it. Hopefully that’s all there is to it.
1 Like
Good call. Yeah I will make a commit to source control before hand. I do have visual studio and the necessary plugins for it already. I did some c++ tutorials a little here and there, but I don’t know enough to do much of anything on my own.
Making a package is good idea to, thanks for the heads up.
1 Like
Okay so I’ve successfully converted the blueprint project into being a c++ project by following the steps listed here: How to Convert a Blueprint Only Project to a C++ Project (using Windows) (allarsblog.com).
I have actually seen how a function can be made blueprint callable before… something to do with adding some UMACRO properties, but there may be more to it than that. I’ll see what I can figure out but if you are still able to help that would be awesome @anonymous_user_3867756a
On creation it is has given me warning here:
“Successfully added class ‘BlueprintFunctions’, however you must recompile the ‘LandNav’ module before it will appear in the Content Browser. Failed to automatically compile the ‘LandNav’ module.”
Not sure if that is important right now or not but I was a little unsure if I should leave this new class in its default directory which was not in the content directory but in the source.
Landnav is the title of the project.
Errors in the Content browser would show in the output log? I combed through it but dont see any errors related to those classes.
oh you know what, i think maybe it couldnt recompile because visual studio wasn’t open.
Okay so I right click the main project called Landnav and hit build. It took awhile but succeeded with no errors or warnings:
The problem is that when I change the world origin, that also moves the mesh distance fields. Just going off of the post I screenshotted above, it sounded like that guy was suggesting that by running that function when doing the origin shift, that would also apply the new offset to the mesh distance fields.
I had to look up what primitive component means. So it sounds like the mesh distance fields would be considered one primitive component? And thus we could point to that, and basically say, “you also should receive the origin shift offset like all the other actors in the scene do.”
There is probably a bit I don’t understand about what the origin shifting is actually doing… I’ll paste the blueprint I use to do that in a sec…
Gotcha.
So I am more or less guessing and I could be way off, but what I believe is happening is that all actors in the scene get effected by the Set World Origin Location when it runs, but the Mesh Distance Fields are ignored.
That’s what it looks like is happening - for instance where water shader colliders with nearby geometry it gets a foam effect, and if i call this Set World Origin Location repeatedly as I move the character the foam part of the water shader keeps moving along with my character. (and the water shader is also depending on mesh distance fields to draw that foam)
Awesome, thank you so much. You are a knight in shining armor.
To make sure I understand correctly, now that I have modified these files, I only need to build them individually then I can test in engine. I don’t need to build the entire project, right?
1 Like

I think this red squiggle on the BlueprintFunctions.h file might be preventing me from finding the node in blueprints. I don’t understand why an #include of the file is included inside itself?
I think it did but i am unfamiliar with compile/build. I don’t understand if this is the same term and what excatly the order of operations needs to be.
I was looking up how to include this header but it sounds like you are saying it’s not necessary to do.
So what I have done so far was right click the project file and click build. No errors there. Back inside Unreal, I can’t find the new node though through search.
After restarting I still cant find it. Tried taking off context sensitive and also looking through list with eyes too, not only text search.
Yeah nothing in level blueprint and that class is missing:

I am thinking it must be related to this problem of the header file not being included. I saw some instruction for manually adding a file to the include list… is that worth trying? There is also the factor of converting this to a c++ project from blueprints… perhaps something that can go wrong there?
Just to be clear, this highlighted file is the one I right click and then build:

and after doing so, here is the output:
Yeah I tried restart editor again and compile, still that class is not appearing. Perhaps I should make a fresh one, just to test and see that I can actually make a class and expose it period.
One thing might be important: when creating the class, I had not set to public or private. By default does that mean it is private? Is that important?