[C++] How can I access variables from a TArray of UChildActorComponents?
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.
https://paste.ee/p/lRrQA (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.
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.
You are not getting an instance, but the default object, which is a static object generated for all uobject classes. This object is not your instance.
Also, try to stick to the Coding Standars for UE4 (I know is just for an assignment, but it makes it easier for people to help you out here) https://docs.unrealengine.com/en-us/Programming/Development/CodingStandard
Follow this question
Once you sign in you will be able to subscribe for any updates here