UE4移動記錄

移動方式一

void ACharacterBase::MoveForward(float speed)
{
    if (speed != 0 && Controller) {
        const FRotator rotation = GetControlRotation();
        const FRotator yawRotaion(0, rotation.Yaw ,0);
        FVector Direction = FRotationMatrix(yawRotaion).GetUnitAxis(EAxis::X);
        AddMovementInput(Direction, speed);
    }
}

void ACharacterBase::MoveRight(float speed)
{
    if (speed != 0 && Controller) {
        const FRotator rotation = GetControlRotation();
        const FRotator yawRotaion(0, rotation.Yaw, 0);
        FVector Direction = FRotationMatrix(yawRotaion).GetUnitAxis(EAxis::Y);
        AddMovementInput(Direction, speed);
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章