【发布时间】:2018-07-31 10:09:49
【问题描述】:
我正在尝试向演员添加事件侦听器,以便在游戏中点击演员时执行某些任务。我已经尝试了多种方法,包括 OnClicked.Add、OnClicked.AddDynamic 以及我在其他答案中看到的每种方法的多个版本,但它们最终都没有编译并给出类似的错误。
这是我现在的课程
// Fill out your copyright notice in the Description page of Project
Settings.
#include "InterestItem1.h"
// Sets default values
AInterestItem1::AInterestItem1()
{
// Set this actor to call Tick() every frame. You can turn this off to
improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AInterestItem1::BeginPlay()
{
Super::BeginPlay();
OnClicked.AddDynamic(this, AInterestItem1::moveToItem);
}
// Called every frame
void AInterestItem1::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AInterestItem1::moveToItem(UPrimitiveComponent* ClickedComp, FKey
ButtonPressed){
UE_LOG(LogTemp, Log, TEXT("meh, they clicked me"));
}
我在 VS 中收到以下错误 没有函数模板“FActorOnClickedSignature::_Internal_AddDynamic”的实例与参数列表匹配
并且在输出日志中出现这个编译错误
CompilerResultsLog: Error: C:\Users\AtLink\Documents\Unreal Projects\Axis_Test_Purged\Source\Axis_Test_Purged\InterestItem1.cpp(18) : error C3867: 'AInterestItem1::moveToItem': non-standard syntax; use '&' to create a pointer to member
CompilerResultsLog: Error: C:\Users\AtLink\Documents\Unreal Projects\Axis_Test_Purged\Source\Axis_Test_Purged\InterestItem1.cpp(18) : error C2672: 'TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,AActor *,FKey>::__Internal_AddDynamic': no matching overloaded function found
CompilerResultsLog: ERROR: UBT ERROR: Failed to produce item: C:\Users\AtLink\Documents\Unreal Projects\Axis_Test_Purged\Binaries\Win64\UE4Editor-Axis_Test_Purged-4805.dll
我是虚幻的新手,所以我可以用一些简单的解释来解释我做错了什么。谢谢。
【问题讨论】:
标签: c++ visual-studio-2017 unreal-engine4