UChildComponentActor->CreateChildActor Compile Error
I'm trying to replicate this tutorial to C++ based project. I have successfully do it in Blue Print before. I'm stuck on imitating the SetViewTargetWithBlend() function. On proper inspection I found that the ChildActor that i throw to that function is actually NULL. Which makes me suspicious that the ChildComponentActor is not poperly Created.
So I add CreateChildActor() to the UChildActorComponent in hope that this function will initialize the assigned child (camera) of my ChildActorComponent. But this throws a Compile Error :
Here's my code so far :
On Character.h I add a USpringArm and UChildActor component :
On Character.cpp Constructor I add this code to Initialize those Actors :
And then I create simple on keyboard press event handler to change the camera which basically said :
Please help, is there any-way I could replicate the usage of ChildComponentActor Blue Print in C++? Or did I not do it properly?
asked Sep 19 '14 at 02:43 AM in C++ Programming
I had the same issue, below worked for me:
Instead of CreateChildActor (which doesn't seem accessible with the default build modules) manually call OnComponentCreated like this childActorComponent->OnComponentCreated();
There seems to be a bug where this particular function is not automatically called in C++ alone (the blueprint node AddChildActorComponent works fine) and the ChildActor within your component ends up never being created unless you use the manual workaround.
See this thread for more details: https://answers.unrealengine.com/questions/41202/oncomponentcreated-not-called-when-using-createdef.html?sort=oldest
Follow this question
Once you sign in you will be able to subscribe for any updates here