Passing UObject to a RPC function doesn't work

Hello guys, I have a simple issue that is blocking me.

I can’t get around how to pass a UObject (ItemObj in screenshot) using a server RPC, it always returns null yet everything else is passed correctly. I have even tried to pass it by reference as I thought it might be a pointers issue in the blueprints background.

Any idea what I could be doing wrong?

A pointer is just that - a pointer to something.
You’re not so much sending data to the server as you are telling the server to point at data it should already have - the screenshot object.

If you want to send the screenshot data from client to server, consider using a byte array or other method.

@Kris You mean by encoding all the data to a byte array then decode it on the server side?

Hi @Branwolv You may need to set Object Reference Variable to Replicate.

@TechLord Thank you for your reply. Yet I read couple posts saying that UObjects don’t replicate and passing them to RPC will always result in them being null. On the UObject level, replication starts from AActors.

Apparantly you can override that in C++ while coding but not in Blueprints modeling. I am trying to find a workaround.

Now that I think about it, that may be why I pass Actors all the time …

So I just realize you are trying to pass an ‘object’ not an aactor. It may not be working because replication starts from AActors. So try passing an AActor, not an object. If the object is just a container for basic datatypes or structs with basic datatypes, try passing the basic datatypes from the object over.

It may also related to where you are trying to send the RPC from, is it a Player Character or Controller?

I ran into something similar a while back. I could not pass the object/actor no matter what, so my workaround was to cache [object name | integer ID ] - to - object reference map on Server/Clients for a performant lookup, then pass the [Object Name|Integer ID] instead of the Object Reference. The Object Names should match up on server/clients. I did not fiddle with C++.

With any luck you could just use the save game system to make a save object and send that.
Otherwise you may have to look for a Blueprint library that lets you do file actions or make your own :expressionless: