438人加入学习
(0人评价)
虚幻5 UE5.4零基础小白入门教程C++版-2025最新版

制作完成于 2025年2月8日 使用虚幻引擎5.4 版本5.4.4,VisualStudio2022

价格 免费

#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);


    }

}

 

 

 


 

[展开全文]

授课教师

SiKi学院老师

课程特色

视频(33)
下载资料(1)

学员动态