头文件定义好之后,我们需要在源文件中将功能具体实现
// 绑定用户按键输入操作
void AAvatar::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
}
从这一段绑定用户按键输入操作我们可以看出来,我们将项目设置中的按键名称与我们的函数功能名
称进行再一次的绑定
void AAvatar::MoveRight(float amount)
{
//若控制器和移动的数值都存在
if (Controller && amount)
{
//获取右转三维向量
FVector right = GetActorRightVector();
//绑定项目设置中按键与头文件中函数功能
InputComponent->BindAxis("MyMoveForward", this, &AAvatar::MoveForward);
InputComponent->BindAxis("MyMoveRight", this, &AAvatar::MoveRight);
Super::SetupPlayerInputComponent(InputComponent);