Learning C++ UE4 Help!

So I’m slowly getting the basics down for the most part, but there’s still stuff that I just don’t understand even after reading… Then reading some more. I’ve got a few questions that I hope someone could help answer better, or explain.

    1. Could someone please explain to me, where the bulk of the code goes when coding a game? Also where are Namespace and Headers defined at, and also how?

      APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
      if (OurPlayerController)
      if (CameraTwo && (OurPlayerController->GetViewTarget() == CameraOne))
      //Blend smoothly to camera two.
      OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
      else if (CameraOne)
      //Cut instantly to camera one.

    1. Could someone explain this code a little bit better for me please? Step by step, with the syntax and what’s going on. For example I don’t understand this.

APlayerController* OurPlayerController
= UGameplayStatics::GetPlayerController(this,

Correct me if I’m wrong please.

APlayerController OurPlayerController* Here APlayerController is an Actor type, and the Asterisk is pointing to OurPlayerController then equal is to UGameplayStatics but what’s this ::GetPlayerController(this, 0) part mean?

Also if anyone has more tutorials step-by-step, or that explains everything I’d gladly appriciate them.


[APlayerController OurPlayerController]*: Pointer of the type, APlayerController, which is named OutPlayerController.

[=]: Assignment Operator which will assign whatever is left of it (OutPlayerController) with whatever is right of it.
[UGameplayStatics]: A class in UE4 which holds a lot of useful tools, often used for Blueprint; also referred to as Kismet in the engine.

[::] Scope Resolution Operator. Used to access something within a different scope, such as a static function in UGameplayStatics.

[GetPlayerController(this, 0);] A function in UGameplayStatics which takes in two arguments, also referred to as parameters. This first is a “WorldContextObject”, used in UE4 as a reference to know what object in the game can be used in this function. The second being a “int32”, which is a whole 32 bit integer, used to get “PlayerIndex”. In this case, the ID given to the PlayerController that this function can use to compare against and return the correct instance you are looking for, or I am guessing a nullptr if the “PlayerIndex” doesn’t match any existing PlayerControllers.