gpt4 book ai didi

c++ - Unreal Engine - 如何通过 C++ 代码获取 AxisMappings

转载 作者:行者123 更新时间:2023-11-28 04:03:06 24 4
gpt4 key购买 nike

我是虚幻引擎和 C++ 的新手...

我正在尝试获取轴的指定键。我发现信息存储在 DefaultInput.ini 文件中,但如何以编程方式访问这些数据?

有一个 GetAxisValue(const FName) 方法,但它不返回任何内容。

FString AxisName = "MoveForward";
auto value = PlayerInputComponent->GetAxisValue(FName(*AxisName));

我做错了什么?非常感谢您的帮助。

最佳答案

我不确定,因为我大部分时间都为此使用蓝图,但获取值的一种方法是将其绑定(bind)到方法。

(AFPS 字符模板示例)

PlayerInputComponent->BindAxis("MoveForward", this, &APawn::MoveForward);

然后在方法中使用它

void AFPSCharacter::MoveForward(float Value){
//for example print the val
UE_LOG(LogTemp, Warning, TEXT("%f"), Value);
}

关于c++ - Unreal Engine - 如何通过 C++ 代码获取 AxisMappings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59183025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com