I’m desperately trying to create a blueprint node that closes my dedicated server. I followed some tutorials on the internet, and this is the best I can achieve:
I created this C++ files by clicking on “New C++ file” in the “File” menu, and by selecting “Blueprint Function Library” as parent class, as seen is some tutorials.
Is this the correct way to achieve what I want to achieve?
Thanks!
That because normal function requires object instance for function to call in your case it would been UCloseDedicatedServer. Btw you would have exact same problem if you would try to use this function in C++.
It will make your function callable without need of object instance, which will make “Target” pin dissapper and your error gone in blueprints and in C++ you will be able to call it with UCloseDedicatedServer::CloseServer(); without object pointer
I assume you using that tutorial in wiki that uses “CompactNodeTitle” in examples, remove it (the , CompactNodeTitle = "Close Server" part) and your nodes will look like normal nodes, CompactNodeTitle is good for simple math nodes on anything else it look ugly
Also don’t make class for each individual node, make single class with all your nodes so you won’t have bunch of pointless classes, it called “Blueprint Library” after all. And also nodes can be created in any C++ class, UBlueprintLibrary is just a class from static functions that don’t belong anywhere.
Just to specify that I had a warning, because my method was private. So I added the “public” keyword in order to get rid of the warning. Here’s the final .h file:
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "CloseDedicatedServer.generated.h"
UCLASS()
class MYPROJECT_API UCloseDedicatedServer : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", DisplayName = "Close Dedicated Server", Keywords = "exit quit close dedicated server"), Category = "Game|Custom")
static void CloseServer();
};