Download

class "APlayerController" has no member "GetPlayerViewPoint" in UE4.21.2

I’m a total noob for UE4. I’m following along with a tutorial where I need to use the GetPlayerViewPoint method on the PlayerController class, however when I try and call that method, I get a compile time error that says: class “APlayerController” has no member “GetPlayerViewPoint” Which is weird because I get autocomplete in Visual Studio for other methods on that class, but not that particular method, BUT I can see that method in the docs here:http://api.unrealengine.com/INT/API/…ler/index.html

Could it be that my compiler and autocomplete are using a different UE4 version than the docs and tutorial? Any ideas why the compiler can’t see that method? Or is there a new way with 4.21 to get the PlayerViewPoint?

Here is my class.




  // Copyright, 2018 #include "BryceEscapeRoomUe4.h" #include "Grabber.h" #include "Runtime/Engine/Classes/GameFramework/Actor.h" #include "Engine/World.h"; #include "GameFramework/PlayerController.h" #define OUT // Sets default values for this component's properties UGrabber::UGrabber() {     // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features     // off to improve performance if you don't need them.     PrimaryComponentTick.bCanEverTick = true;      // ... }   // Called when the game starts void UGrabber::BeginPlay() {     Super::BeginPlay();      UE_LOG(LogTemp, Warning, TEXT("Grabber repoting for duty!"));  }   // Called every frame void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) {     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);      // get player view point this tick     FVector  PlayerVeiwPointLocation;     FRotator PlayerVeiwPointRotaion;     GetWorld()->GetFirstPlayerController()->GetPlayerVeiwPoint(         OUT PlayerVeiwPointLocation,         OUT PlayerVeiwPointRotaion     );     //log out to test       //ray cast out to reach distance      // see what we hit } 

In you code sample (which hasn’t survived the copy-paste very well) you have misspelled the function as “GetPlayerVeiwPoint” which wont help. That’s the only problem I can think of.

Ha Ha. That was it. I’m an idiot. Thanks!!

hello i have a similar issue im following the same course u mentioned and when i use GetWorld()->GetFirstPlayerController in intellisense i get this error :no members available.i also included the header file in the bottom of this site http://api.unrealengine.com/INT/API/…ler/index.html. whats the problem? im struggling with this problem for around one week.
thanks in advance.

GetFirstPlayerController is in


"Engine/World.h"

. When you include something new you should refresh your project using the UE4 VS plugin or you can trigger it by the context menu “Generate Visual studio Project files” on the UProject file. The intellisense is just a guide though and often it will compile regardless of what intellisense claims however it is a good habit to include things explicitly so the code doen’t break when a prerequisite is no longer present.

thanks for your quick response.i know GetFirstPlayerController is in Engine/World.h header file but i thing i didn’t state my problem well.im trying to access a member of GetFirstPlayerController not itself.once this problem happened to me and i tried to fix it using another thing but i encountered this again.anyways im trying to access this:GetWorld()->GetFirstPlayerController->GetPlayerViewpoint() or GetPawn() method and i also included #include “GameFramework/PlayerController.h”.but still the same and about that u say i should refresh my project i tried to ignore intellisense but the problem doesn’t disappear.in this case what should i do ?
thanks in advance!

Sorry I didn’t notice you already included that, it is a bit hard to read all in one line.

What is the deal with the Define OUT? I don’t see the point in that.

im not the one who started this topic but im following the same tutorial he does OUT is only a tip to the designer nothing important. i really dunno why it doesn’t work for me that kinda weird for me to i included related header and trying to use the code but doesn’t work omg what is this error at all :(((