Get Player Contrller in pawn code example

Example: get player pawn

//file to include
#include "Kismet/GameplayStatics.h"

//Syntax
static APawn * GetPlayerPawn(const UObject * WorldContextObject, int32 PlayerIndex);

//ExampleCode
APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
//								this is a reference to world  | This is the index of player which you want. In this case  have written 0 that means the first player
//For more information vist https://docs.unrealengine.com/en-US/API/Runtime/Engine/Kismet/UGameplayStatics/GetPlayerPawn/index.html

Tags:

Cpp Example