I have a Question about Get Reference from child actor in C++ code.
I want to get a reference to a class in the program code in order to call a function of the class that the child Actor inherits from.
Specifically, is it possible to do the following link in C++?
[Actor reference from child actor component][1]
I tried to get it in the code, but what I can get is the USeneComponent type.
I can’t cast it to a class.
USceneComponent* Test = RootComponent->GetChildComponent(0);
TestClass* TestReference = Cast<TestClass>(Test);// it is impossible
Child actor component is a component “containing” actor, or rether operating actor so it acts like component, by moving it to component world position on every tick and handle its life cycle (spawning and destroying) to keep in sync with parent actor. Child Actor Component is a component, and component is not actor and vice versa, so you cant cast it. What you getting is child actor component class so you should cast to that
From there you can use GetChildActor() to get actor from component
Hello! What is TestClass class? Actor classes start with A letter (for example AActor), while Component classes start with U letter (for example, USceneComponent).