Creating an instance of an actor?

Just a quick one, I know that you should ‘Spawn’ actors in the world, but is there any reason why I can’t just go new AActor(params); etc.?

I know they’ve now removed the need for const FObjectInitializer& ObjectInitializer so I have removed this from most of my constructors.

If you look at the definition for SpawnActor, and then at the definition for ConstructObject (since Actor is a UObject), you’ll see a lot more goes on then simply "new"ing the object. Unreal has its own memory management system so you don’t have to worry about calling delete. You can always force garbage collection if you know its a good time in your game for GC to happen. Furthermore, an Actor has to be registered to a scene/level/network/etc which all happens in SpawnActor.

So basically SpawnActor is designed to make your life easy.

ok then thanks, is there a good way to get an exact clone of another actor?

I’ve been trying to use SpawnActor() Spawnparams etc. setting the template, but I can’t get it working?

Try setting to the template as the Actor you want to clone?