如何修复错误标识符“ PlayerViewPointLocation”未定义

时间:2019-04-20 04:49:14

标签: c++ visual-studio-2015 unreal-engine4

我正在关注教程https://www.udemy.com/unrealcourse/learn/lecture/4690340?start=150#overview 它是在Visual Studio 2015之前制作的,所以我认为我缺少一个包含文件,但是不确定哪个或我是否缺少其他文件。 这是错误所在的函数:

#include "Grabber.h"
#include "Gameframework/Actor.h"
#include "DrawDebugHelpers.h"


#define OUT


// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    // get player view point this tick
    FVector PlayerViewpointLocation;
    FRotator PlayerViewPointRotation;
    GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
        OUT PlayerViewpointLocation,
        OUT PlayerViewPointRotation
    );

    //logout to test
    /*UE_LOG(LogTemp, Warning, TEXT("Location: %s, Rotation: %s!"), *PlayerViewpointLocation.ToString(), *PlayerViewPointRotation.ToString());*/

    FVector LineTraceEnd = PlayerViewPointLocation /* the error is right here*/ + FVector(0.f, 0.f, 20.f);

    // draw a red trace in the world to visual
    DrawDebugLine(
        GetWorld(),
        PlayerViewpointLocation,
        LineTraceEnd,
        FColor(255, 0, 0),
        false,
        0.f,
        0.f,
        10.f
        );

    // ray cast out to reach distance

    //see what we hit
}

1 个答案:

答案 0 :(得分:0)

将声明中的p大写

// get player view point this tick
FVector PlayerViewpointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
    OUT PlayerViewpointLocation,
    OUT PlayerViewPointRotation
);