1
\$\begingroup\$

I would like to expose to blueprints the variable CurrentTouchInterface in the class APlayerController, just like the method APlayerController::ActivateTouchInterface.

So, I'm guessing I have to change the header file PlayerController.h from this

/** The currently set touch interface */
UPROPERTY()
class UTouchInterface* CurrentTouchInterface;

To something like this

/** The currently set touch interface */
UPROPERTY(BlueprintReadOnly, Category="Game|Player")
class UTouchInterface* CurrentTouchInterface;

The point is, what do I need to do for the engine's editor to start showing the exposed variable CurrentTouchInterface in blueprints?

I'm working with UE 4.9 downloaded from the Epic Games Launcher application.

\$\endgroup\$
1
\$\begingroup\$

Since you are not compiling the Unreal Engine source code, any changes you make in the PlayerController.h file will be ignored. If you are prepared to modify the source, you can do the step you outlined in your question and compile the editor. You can read more about compiling the editor on the Unreal website.

However, it would be easier (and probably cleaner as you won't be running a custom version of Unreal), to create a helper function that takes a player controller and gets the current touch interface. Something like this (inside any class will do, but I like to have a class just for static blueprint functions):

UFUNCTION(BlueprintPure, Category = "Game|Player")
static class UTouchInterface* GetPlayerCurrentTouchInterface(APlayerController* Controller);

Then the implementation would just be:

return Controller->CurrentTouchInterface;

In the blueprint editor, you will be able to drag out from a player controller variable and get this node.

\$\endgroup\$
  • \$\begingroup\$ Ok, I'll try something like this, by the way, do you know where do I have to put those new clases in the project folder on a Mac? \$\endgroup\$ – rraallvv Oct 29 '15 at 14:22
  • \$\begingroup\$ I imagine in the Source/ProjectName/ folder (but I'm on Windows). However, in the editor there is a command to create a new class. It can be reached from "File>New C++ Class". This will generate the files in the right place with some required boilerplate code. It doesn't matter what you derive from since your functions are static, but I use UBlueprintFunctionLibrary to make its purpose clear. \$\endgroup\$ – T. Kiley Oct 29 '15 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.