x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Replication of TScriptInterface C++

Hi!

I have problems with getting my interface to replicate. I have a BaseItemInterface and different Items that implements the interface. I try to replicate the interface something like this:

UPROPERTY(Replicated)

TScriptInterface< BaseItemInterface > MyInterface;

It doesnt work.

But when I replicate my raw Item class, ex. ToolItem

UPROPERTY(Replicated)

ToolItem* MyItem;

It works for that object.

Can UE4 handle Interface objects Replication or do I need to add some more code anywhere? I've done the bReplicates = true & DOREPLIFETIME(YOUR_CLASS_NAME, PropName); thingy according to https://wiki.unrealengine.com/Networking/Replication

Thanks!

Product Version: UE 4.8
Tags:
more ▼

asked Aug 20 '15 at 02:03 PM in C++ Programming

avatar image

State128
73 5 9 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

TScriptInterface<..> does not currently get replicated by UE4. I actually think it should give an error when you try to do it, but it just silently fails.

Anyway, TScriptInterface<..> is basically just two things, a pointer to your UObject, and then a cached pointer to the Interface part of your UObject that you're interested in.

The way I would do it right now, given the current limitations, would be to replicate a regular UObject or AActor pointer as a private property, and give access to getting/setting it through public members which only allow TScriptInterface<..> as the argument. The getter would cast from the UObject property to the interface that you want. Enforcing it this way would reduce the chances that a mistake is made elsewhere in the code.

more ▼

answered Aug 20 '15 at 02:17 PM

avatar image

cancel
2.4k 101 72 124

avatar image State128 Aug 21 '15 at 10:25 AM

Thanks for clarifying that, it make sense.
I'll have to implement some sort of type translation as you mentioned.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question