Hello!
I’m working on a project with some friends and we want to create a tool to help our game designers to tweak all game feel (and 3C) related variables. We want the tool to be used in editor mode but also during the play mode (PIE). The changes made during the play mode must be applied on the object even if we stop the play mode.
**The current work : **
- I created an empty c++ project, called ActorLinking, to make things easier. I created a dummy actor, called TheActor. This actor is a part of the project.
- Then I created a small plugin, called ThePlugin, to add a button in the editor.
- When I click on this button, I retrieve the dummy actor in the scene from the editor world or the engine world.
**The problem : **
- I get a linker error when I try to use any functions of this actor (See image)
**The project file : (.uproject) **
{
"FileVersion": 3,
"EngineAssociation": "4.21",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "ActorLinking",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
]
}
**The actor header : **
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TheActor.generated.h"
UCLASS()
class ACTORLINKING_API ATheActor : public AActor
{
GENERATED_BODY()
public:
ATheActor();
UFUNCTION()
void MoveActor();
protected:
virtual void BeginPlay() override;
public:
virtual void Tick(float DeltaTime) override;
};
The actor implementation : (TheActor.cpp)
#include "TheActor.h"
ATheActor::ATheActor() {
PrimaryActorTick.bCanEverTick = true;
}
void ATheActor::BeginPlay() {
Super::BeginPlay();
}
void ATheActor::MoveActor() {
UE_LOG(LogTemp, Warning, TEXT("MoveActor"));
}
void ATheActor::Tick(float DeltaTime) {
Super::Tick(DeltaTime);
}
**And now the code of the plugin : (.uplugin) **
{
[...]
"Modules": [
{
"Name": "ThePlugin",
"Type": "Editor",
"LoadingPhase": "Default",
}
]
}
The build file (ThePlugin.Build.cs) :
using UnrealBuildTool;
public class ThePlugin : ModuleRules
{
public ThePlugin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange (new string[] {});
PrivateIncludePaths.AddRange(new string[] {});
PublicDependencyModuleNames.AddRange (new string[] {"Core", "ActorLinking" });
PrivateDependencyModuleNames.AddRange(
new string[]
{
"Projects",
"InputCore",
"UnrealEd",
"LevelEditor",
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"ActorLinking" // The module of the project
}
);
DynamicallyLoadedModuleNames.AddRange(new string[]{});
}
}
And finally the code causing the linker error : (ThePlugin.cpp)
void FThePluginModule::PluginButtonClicked()
{
[...]
ATheActor* p_actor = nullptr;
/* Getting the actor */
p_actor ->MoveActor(); // MoveActor undefined reference
[...]
}
I’m new to Unreal Engine so it makes me think I’m doing it wrong. I’m trying to figure out why it doesn’t work. It seems to work with propertyies but not with functions. I’m unable to find appropriate ressources that’s why I’m posting here. Thank you for your help!