Creating a simple object in UE4 C++ code does not work
Hey guys, I cant seem to make create a simple object in ue4 c++. I have these two different classes: RandomGenActor.h - > UClass of AActor RandomGenActor.cpp
and another CarClass.h -> is just a blank class CarClass.cpp
And what I want to do is to create an object of CarClass inside RandomGenActor, here's what I want to do: to declare
but I'm getting compilation errors, any idea what is the proper way to do this? Thanks!
asked Sep 11 '16 at 10:12 AM in C++ Programming
While that's the typical C++ way of creating a new object, you want to use UWorld::SpawnActor so that it registers your object in the engine properly.
answered Sep 11 '16 at 08:20 PM
I do this. I just declare it (my custom class) as an instance variable as part of my AActor derived class and I don't have the compile issues. However it is problematic if the actor gets re-used or serialised from some reason.
answered Sep 14 '16 at 07:50 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here