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

Calling native UInterface functions from C++

Follow the previous recipe to get an understanding of casting an Actor pointer to an Interface pointer.

Note

Note that as this recipe relies on the casting technique used in the previous recipe, it will only work with objects that implement the interface using C++ rather than Blueprint. This is because Blueprint classes are not available at compile time, and so, technically, don't inherit the interface.

How to do it...

  1. Create a new Actor class using the editor wizard. Call it AntiGravityVolume.
  2. Add BoxComponent to the new Actor.
    UPROPERTY()
    UBoxComponent* CollisionComponent;
  3. Override the following Actor virtual functions in the header:
    virtual void NotifyActorBeginOverlap(AActor* OtherActor) override; virtual ...

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