#include "InputActionValue.h"
protected:
//声明移动和视角移动的函数,并且有个Value常量
vo id Move(const FInputActionValue& Value);
void Look(const FInputActionValue& Value);
void AMyPlayer::Move(const FInputActionValue& Value)
{
//获取Velue里面的一个2D值并且赋予给MovementVector
FVector2D MovementVector = Value.Get<FVector2D>();
if (Controller!=nullptr)
{
const FRotator Rotation = Controller->GetControlRotation();
//点头pitch ,摇头Yaw.偏头row.
const FRotator YawRotation(0,0,Rotation.Yaw);
//获取前后左右向量
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
//添加移动输入
AddMovementInput(ForwardDirection,MovementVector.X);
AddMovementInput(RightDirection, MovementVector.Y);
}
}