Is network replication only accessible by UClasses?

Good afternoon UE4,

For the last weeks I’ve been making an engine which is not based on the Objects class - to save overhead mostly - but on empty classes instead. Now I’ve realized I have forgotten a crucial point: I will need some replication, not in keeping variables replicated in those classes, but instead, to remotely call functions (basically, having Client/Server/Multicast functions). In order to do so, the methods will have to be in UClass derived classes, or will it work on my empty classes as long as I include UnrealNetworking.h?

Same for using FTimers in a class’ methods.

In order to make use of the UE networking stuff, they do indeed have to be UCLASSES. By default, only Actors and Actor Components have access to that replication stuff too I believe - though you can include the required headers and add your own replication functionality to UObjects as well, but there is a lot of underlying code you need to put in place for that.

Unless you’re doing something particularly special, every class you make should really inherit from UObject. The only time I’ve seen anything done in standard C++ was an AI engine, which was written in such a way that it could be simulated extremely fast outside of the engine for testing and iteration. 99% of the time, there’s no need to step away from the engines classes.

Sorry to be the bearer of bad news!

Well maybe you’re right, I just feel like its going to have a big impact on the engine and I need it as fast as it can possibly be since it includes a lot of math.

Small additional question: it says that in the case of UObject derived classes, garbage collection is automated. This is the case when we specify UPROPERTY() UCLASS() UBODY() etc macros correct? Or is it automated? And does it only process the garbage from UObject derived classes, or from others as well?

class Base : UObject
     NotBase* nb = new NotBase();

class NotBase : API

In the case of something like that, would nb get recicled and cleaned automatically as well?

“A lot of math” - are we talking about 20 million operations per second here? Because otherwise your cpu most likely will be able to handle that with ease.

What you’re trying to do smells a lot like premature optimization.

Make working prototype first, using uclasses, and if it is slow, start optimizing.

According to the wiki, anything that is not UObject-based will not be garbage collected. Which makes sense.

No need to be rude there, still, thank you for the information.

Yeah, the Garbage Collector only works for UClass / UProperties. While you can still do you’re own memory management with malloc, new and delete etc it’s probably easier not too.

As NegInfinity says, unless you’re calculating the physics of galaxies the overhead of a UObject and in many cases even an Actor will be the least of your worries. If you want to simulate it that quickly, my suggestion would be to write an external .dll that runs of it’s own accord, and the editor just reads in and passes information around from it via an Actor. Hard to say without details on what you’re trying to do though.