Cory

View Original

Integrating C++ and Blueprints

This semester I used one project for multiple classes. One was an entry-level game design course where we used Blueprints to script and another was a programming course where we use C++. We started by creating a Base Pickup using C++ and inheriting from that class, creating multiple pickups. Health, Shield, Spring Shoes, and Speed Boost.

We’re also using an interface to share functions between the Pickup and the player.

iInteract.h

#pragma once

#include "CoreMinimal.h"

#include "UObject/Interface.h"

#include "iInteract.generated.h"

// This class does not need to be modified.

UINTERFACE(MinimalAPI)

class UiInteract : public UInterface;

class WVDOOM_API IiInteract

{

GENERATED_BODY()

// Add interface functions to this class. This is the class that will be inherited to implement this interface.

public:

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")

void OnInteract(AActor* PlayerActor);

};

iInteract.cpp

See this content in the original post

Pickup.h

See this content in the original post

Pickup.cpp

See this content in the original post

We haven’t implemented the interface yet as the current character does not inherit from a C++ class but will in the future.

Creating a Blueprint from this C++ class and then make children of that Blueprint.

One of the biggest problems with using this kind of project between a group of new students and more experienced students is that the newer students felt overwhelmed with generating the project files, making sure they had all the proper SDK’s when many had never heard of an SDK before. All the students were able to compile the project and eventually got more comfortable with the process.

The project is still being used in some of the classes and can be found here.