Unreal中Input的设定

首先在编辑器中,Settting->ProjectSettings->Input中设置

Unreal中Input的设定_第1张图片

然后代码的

// Called to bind functionality to input
void AAvatar::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	Super::SetupPlayerInputComponent(InputComponent);
    InputComponent->BindAxis("Forward", this, &AAvatar::MoveForward);
    InputComponent->BindAxis("Strafe", this, &AAvatar::MoveForward);
}

void AAvatar::MoveForward(float amount)
{
    if(Controller && amount)
    {
        FVector fwd = GetActorForwardVector();
        AddMovementInput(fwd, amount);
    }
}

void AAvatar::MoveRight(float amount)
{
    if(Controller && amount)
    {
        FVector right = GetActorRightVector();
        AddMovementInput(right, amount);
    }
}


你可能感兴趣的:(Unreal)