本文参考了UE4官方教程《BP 3rd Person Game FBX Importing & Using Skeletons 03 v4.8 Tutorial Series Unreal Engine》
文章目录
设置输入控制的位置
- 设置输入控制的位置
- Action Mappings和Axis Mappings
- 在C++中绑定回调函数
ProjectSettings>Engine>Input
- 动作映射(
Action Mappings
)
瞬时事件,主要用于按键的按下和抬起。只有当这两个事件发生时,相应的回调函数才会被调用。
- 轴映射(
Axis Mappings
)
持续事件,相应的回调函数会一直被调用,用户有相应的操作时,会影响传入回调函数的参数值。
可以将常用的配置导出成ini文件,供其它项目使用。
InputComponent->BindAxis("MoveForward", this, &ADemoCharacter::MoveForward);
InputComponent->BindAction("Jump", IE_Pressed, this, &ADemoCharacter::OnJump);
其中MoveForward
和OnJump
的原型分别为:
void ADemoCharacter::MoveForward(float value);
void ADemoCharacter::OnJump();