As part of my assignment (due in next month), I am trying to recreate a space game using C++ to exercise my knowledge in OOP - I admit that I am somewhat new to C++, but I have had far more extensive use of C# in the past. I’ve right now made a few classes to test things out.
I am trying to get a Pawn C++ class to access variables in the UChildActorComponents that I have added to it. The UChildActorComponents have their own type that inherit from AActor. The code I will provide will be in the following link - I apologize in advance if it’s very rough.
Paste.ee (lasts around one year from now).
The key points to take away from here is that in line 59 of TestPawn.cpp in the above link, I often receive nullptr errors. I don’t know how to resolve this.
p_im = this->cubeComps[0]->GetChildActorClass()->GetDefaultObject<ATestCubeComponent>()->p_isMaster;
Feel free to advise me also on how else I could do this code. The key requirements are for me to create classes that can move and fire, with each of them having at least one or multiple components.