【请教】如何在C++中创建按键个事件。如图
【请教】如何在C++中创建这样的按键个事件。如图我想使用
PlayerInputComponent->BindKey(EKeys::A, IE_Released, this, &AThePlayer::ChangeWeapons);
然后
void AThePlayer::ChangeWeapons(){}
但是一直提示我错误:
CompilerResultsLog: Error: ThePlayer.cpp.obj : error LNK2019: ?????????ⲿ???? "__declspec(dllimport) public: __cdecl FInputChord::FInputChord(struct FKey,bool,bool,bool,bool)" (__imp_??0FInputChord@@QEAA@UFKey@@_N111@Z)???÷????ں??? "public: virtual void __cdecl AThePlayer::SetupPlayerInputComponent(class UInputComponent *)" (?SetupPlayerInputComponent@AThePl
ayer@@UEAAXPEAVUInputComponent@@@Z) ?б?????
CompilerResultsLog: Error: ThePlayer.cpp.obj : error LNK2019: ?????????ⲿ???? "__declspec(dllimport) public: __cdecl FInputChord::FInputChord(struct FInputChord const &)" (__imp_??0FInputChord@@QEAA@AEBU0@@Z)???÷????ں??? "public: struct FInputKeyBinding & __cdecl UInputComponent::BindKey<class AThePlayer>(struct FInputChord,enum EInputEvent,class AThePlayer
*,void (__cdecl AThePlayer::*)(void))" (??$BindKey@VAThePlayer@@@UInputComponent@@QEAAAEAUFInputKeyBinding@@UFInputChord@@W4EInputEvent@@PEAVAThePlayer@@P84@EAAXXZ@Z) ?б?????
CompilerResultsLog: Error: ThePlayer.cpp.obj : error LNK2019: ?????????ⲿ???? "__declspec(dllimport) public: __cdecl FInputChord::~FInputChord(void)" (__imp_??1FInputChord@@QEAA@XZ)???÷????ں??? "public: struct FInputKeyBinding & __cdecl UInputComponent::BindKey<class AThePlayer>(struct FInputChord,enum EInputEvent,class AThePlayer *,void (__cdecl AThePlayer:
:*)(void))" (??$BindKey@VAThePlayer@@@UInputComponent@@QEAAAEAUFInputKeyBinding@@UFInputChord@@W4EInputEvent@@PEAVAThePlayer@@P84@EAAXXZ@Z) ?б?????
CompilerResultsLog: Error: E:\UE4gongcheng\4.18C++\TheExecutioner\Binaries\Win64\UE4Editor-TheExecutioner-7003.dll : fatal error LNK1120: 3 ???????????ⲿ????
CompilerResultsLog: ERROR: UBT ERROR: Failed to produce item: E:\UE4gongcheng\4.18C++\TheExecutioner\Binaries\Win64\UE4Editor-TheExecutioner-7003.dll
我该如何更正?同时我想调用图一中的Key结构体。我又该怎么做
本帖最后由 mknmknmk 于 2018-4-13 08:22 编辑
请写在pawn 里
PlayerInputComponent 在actor 不存在的,
但是 你可以在 Actor 添加 UPROPERTY() UInputComponent *PlayerInputComponent ;
构造函数里初始化它,进行绑定。添加EnableInput(this);
或者在tick 里检检查按键是否按下。
本帖最后由 mknmknmk 于 2018-4-13 08:27 编辑
SetupPlayerInputComponentactor里没有此虚方法
检查 Build.cs 是否 有
PublicDependencyModuleNames.AddRange(new string[] { "Core",
"CoreUObject",
"Engine",
"InputCore",
"RenderCore",
"RHI"
});
工程名.h 是否包含以下2两句
#include "CoreMinimal.h"
#include "Engine.h"
https://answers.unrealengine.com/questions/617654/how-can-i-create-a-player-input-component-in-an-ac.html tick 里获取 事件
https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/533-input-held-down mknmknmk 发表于 2018-4-13 08:16
请写在pawn 里
PlayerInputComponent 在actor 不存在的,
我这边使用的是pawn类,我BindAction和BindAxis函数都可以用,现在想尝试一下BindKey 的用法。以及想尝试下获取BindKey中Key的结构体
页:
[1]