Unreal is failing to create pointer objects

I think this problem started happening when I updated to 4.9, but I think I am missing something too, ignoring something idk why, this objects are in my character header file:

	APlayerCameraManager* GPCM = UGameplayStatics::GetPlayerCameraManager(this, 0);
	APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);

Everytime I try to use the object in the character CPP file, Unreal crashes, something like:

PC->PlayCameraAnim(Params & stuff goes here)

This is driving me crazy, I don’t know how is this happening, I tried declaring the objects as public, private and protected but Unreal keeps crashing, the only way I can avoid this is to declare the object Inside a function, but this means creating the object multiple times over the cpp and I don’t want that.

¿What could it be?

I tried this before too, I placed it in the character constructor on CPP, but again, is not working, the engine keeps crashing, is weird because this used to work without problems.

Visual Studio keeps telling me that the variables or values of PC or GPCM are NULL or the memory was unable to read

Ok, so it seems if I place:

	this->GPCM = UGameplayStatics::GetPlayerCameraManager(this, 0);
	this->PC = UGameplayStatics::GetPlayerController(this, 0);

On a function, in this case, the Tick function. The Engine don’t crash, but why?

I don’t think you should define your variables in the header. You simply declare them.
This means in the header you do:

APlayerCameraManager* GPCM;

and then in your .cpp file at some point you can say

this->GPCM = UGameplayStatics::GetPlayerCameraManager(this, 0);

Depending on what object this is, the constructor might be too early, so the CameraManager and/or PlayerController don’t exist yet. Try the BeginPlay function. I’m not sure if the object gets ticked before that. If it does, check whether the references are valid before trying to call any functions on them.

In the constructor you might try to access uninitialized contents.

I don’t know in which function you’re trying this but you could try setting it up in
BeginPlay() // for actors
PostInitProperties() // for any uobjects

Thanks for the replies, im going to try to place them in the BeginPlay function