Hi everyone, I’m trying to bind my InputAction to a function in a Pawn subclass but I get these linker errors:
Error LNK2019 unresolved external symbol "__declspec(dllimport) unsigned long __cdecl Windows::GetCurrentThreadId(void)" (__imp_?GetCurrentThreadId@Windows@@YAKXZ) referenced in function "public: __cdecl TDelegateAccessHandlerBase<struct FNotThreadSafeDelegateMode>::FReadAccessScope::FReadAccessScope(class FMRSWRecursiveAccessDetector const &)" (??0FReadAccessScope@?$TDelegateAccessHandlerBase@UFNotThreadSafeDelegateMode@@@@QEAA@AEBVFMRSWRecursiveAccessDetector@@@Z)
Error LNK2019 unresolved external symbol "__declspec(dllimport) void __cdecl Windows::EnterCriticalSection(struct _RTL_CRITICAL_SECTION *)" (__imp_?EnterCriticalSection@Windows@@YAXPEAU_RTL_CRITICAL_SECTION@@@Z) referenced in function "public: __cdecl FScopeLock::FScopeLock(class FWindowsCriticalSection *)" (??0FScopeLock@@QEAA@PEAVFWindowsCriticalSection@@@Z)
Error LNK2019 unresolved external symbol "__declspec(dllimport) void __cdecl Windows::LeaveCriticalSection(struct _RTL_CRITICAL_SECTION *)" (__imp_?LeaveCriticalSection@Windows@@YAXPEAU_RTL_CRITICAL_SECTION@@@Z) referenced in function "public: void __cdecl FScopeLock::Unlock(void)" (?Unlock@FScopeLock@@QEAAXXZ) Traversal
*.Build.cs
:
public class Traversal : ModuleRules
{
public Traversal(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] {
"Core",
"CoreUObject",
"Engine",
"EnhancedInput",
"InputCore",
"UMG",
"Slate",
"SlateCore"
});
PrivateDependencyModuleNames.AddRange(new string[] { });
}
}
MyPawn.h
:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "MyPawn.generated.h"
UCLASS()
class TRAVERSAL_API AMyPawn : public APawn
{
GENERATED_BODY()
public:
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
UFUNCTION()
void OnInputActionTriggered();
UPROPERTY(EditDefaultsOnly, Category = "Input")
TObjectPtr<class UInputAction> MyInputAction;
};
MyPawn.cpp
:
#include "MyPawn.h"
#include "EnhancedInputComponent.h"
#include "InputAction.h"
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
auto* Input = Cast<UEnhancedInputComponent>(PlayerInputComponent);
Input->BindAction(
MyInputAction, ETriggerEvent::Triggered, this, &AMyPawn::OnInputActionTriggered);
}
void AMyPawn::OnInputActionTriggered()
{
}
The problem is the row Input->BindAction(MyInputAction, ETriggerEvent::Triggered, this, &AMyPawn::OnInputActionTriggered);
because if I comment that the problem disappears.