How do I set a pointer to the class it is used in?

I am currently having a problem with a pointer.

I need to call a function that is supposed to be called like this:


 myVariable = pControllerScript->GetScriptB()-GetScriptC()->GiveMeMyData();

the ControllerScript is a Avatar class and also the script I am trying to call GiveMeMyData() from

The problem is that I cant seem to set pControllerScript so that it is an actual pointer to the Avatar class.

The code throws an exception at GetScriptB() and it seems to be because pControllerScript is a nullpointer.

Does anyone know how I am supposed to set pControllerScript to an actual pointer?

Sorry if this is noobish, i just find this one thing so confusing

Well, if the class you’re currently writing a function for is derived from the Avatar class, then you should be able to just call the function directly.


myVariable = GetScriptB()->GetScriptC()->GiveMeMyData();

Alternatively, if you need to get a pointer to the class you’re currently using for any other reason, in C++ it is just the “this” keyword; e.g.


//If this class is derived from AActor
AActor* MyPointer = this;