O'Reilly logo

Unreal Engine 4 Scripting with C++ Cookbook by Stephen Whittle, William Sherif

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating functions that can be called in Blueprint

While marking classes as BlueprintType or Blueprintable allows us to pass instances of the class around in Blueprint, or to subclass the type with a Blueprint class, those specifiers don't actually say anything about member functions or variables, and if they should be exposed to Blueprint.

This recipe shows you how to mark a function so that it can be called within Blueprint graphs.

How to do it…

  1. Create a new Actor class using the editor. Call the actor SlidingDoor.
  2. Add the following UPROPERTY to the new class:
    UFUNCTION(BlueprintCallable, Category = Door)
    void Open();
    UPROPERTY()
    bool IsOpen;
    
    UPROPERTY()
    FVector TargetLocation;
  3. Create the class implementation by adding the following to the .cpp file: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required