【问题标题】:How to fix error identifier "PlayerViewPointLocation" is undefined如何修复错误标识符“PlayerViewPointLocation”未定义
【发布时间】:2019-04-20 04:49:14
【问题描述】:

我正在关注教程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
}

【问题讨论】:

  • PlayerViewPointLocation -- 这没有在您的代码中的任何地方定义。被声明的称为PlayerViewpointLocation。 C++ 是区分大小写的,如果你还不知道的话。
  • 哦,谢谢你修好了。

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


【解决方案1】:

将声明中的 p 大写

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

【讨论】:

  • 对不起,我没有告诉你错误在哪里,它不在这里。
猜你喜欢
  • 1970-01-01
  • 2018-06-30
  • 1970-01-01
  • 2015-10-11
  • 2014-06-05
  • 2015-05-12
  • 2012-02-26
  • 2011-10-23
  • 1970-01-01
相关资源
最近更新 更多