I don’t want it as a spawnable object, I want UItemBase as items in for example an inventory. I really want to know how I get the item from the server, without the client ever having any information about the item before asking for it (for cheating purposes).
You’ll need a DOREPLIFETIME for each property you mark as replicated.
There will likely be some other steps to get the object as a whole to replicate, since it’s not an AActor. You’ll need to override ReplicateSubobjects on whatever object owns a reference to the item.
The first class in the UObject class hierarchy that implements replication is AActor. All game relevant objects that you wish to be shared between server and clients have to be Actors.
UObject is the most basic class in the Engine’s object system. You can think of it as ‘object’ in C# and Java. A game can have tens of thousands of UObject instances at any given time, many of which are not even relevant to the game. Imagine what would happen if they were all replicated! Hence it is the purpose of AActor to implement game relevant classes that can be replicated.
You said you like UObjects because they are easier to create. Are you perhaps using them simply to transfer data? In that case you may want to consider UStruct properties on your Actors.
If you are using the UObjects to replicate or share behavior, then you may want to consider function replication on your Actor instead.
If you are looking for a way to share data or behavior between different actor classes, or if you want to compartmentalize it to better structure your code, you may also consider Replicated Actor Components.
UE4’s replication system by default will not allow cheating if used properly. Since the things you do not want the client to know about, are ran only on the server.
My inventory system’s base item is an AActor and I tried to use cheat engine and like software to attempt to cheat with duping and modify values and stuff and it was fine i could not get anything to work client side.
Hm, I guess I could try to make it an actor instead.
EDIT: I tried that, but then when I play the game, it triggers a breakpoint at void CastLogError(const TCHAR* FromType, const TCHAR* ToType) { UE_LOG(LogCasts, Fatal, TEXT("Cast of %s to %s failed"), FromType, ToType); }. I used Visual Assist X to rename, so it’s not because I forgot something (I made my UItemBase class inherit from AActor, and then renamed it to AItemBase).
Do you still have the UObject overriden function ? I’m not sure that works in AActor. Try removing that. If it doesn’t work. What i would do is this,
Adding a new c++ aactor class from the UE4 Editor Menu, and retype only your needed implementations of the baseitem back into the new aactor.