1 在AuraPlayerController中
增加virtual SetupInputComponent();//需要增加EnhancedInputComponent.h
{
UEnhancedInputComponent* InputComponent = Castchecked<UEnhancedInputComponent>(InputComponent);
}
2 在AuraPlayerController.h中
增加TObjectPtr<UInputAction> MoveAction;
void Move(cont FInputActionValue& InputActionValue);
3 在AuraPlayerController.cpp中
补充SetupInputComponent()
{
EnhancedInputComponent->BindAction(MoveAction,ETriggerEvent::Triggered,this,&AAuraPlayerController::Move);
}
Move()
{
const FVector2D InputAxisVector = InputActionView.Get<FVectot2D>();
const FRotator Rotation = GetControlRotation();
const FRotator YawRotation(0.f,Rotation.Yaw,0.f);
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
if(APawn* ControllerPawn = GetPawn<APawn>())
{
ControlledPawn->AddMovementInput(ForwardDirection,InputAxisVector,Y);
ControlledPawn->AddMovementInput(RightDirection ,InputAxisVector,X);
}
}
4 创建BP_AuraPlayerController,并将增强输入的两个资产使用上;
