Edit 3: I am now creating the deck entirely in blueprints. I call a BlueprintImplementableEvent in C++ to create the deck. It goes through a For loop, creating each card. Every time the index changes I set a variable to the new index (the index number controls the scalar parameter to set the texture of the card material). The index is RepNotify so it calls a function to then set the material. Once again, it doesn’t work on the client. I’m thinking the problem might be elsewhere.
Edit 2: I managed to get rid of the LogNetPackageMap
warnings by creating a blueprint of the card, setting up the dynamic material in the construction script of the card’s blueprint, and then spawning the blueprint cards in C++. However, I still can’t manage to replicate the material. I tried making a multicast function in blueprints themselves via a BlueprintImplementableEvent that got called first, Repnotify in C++, and Multicast in C++. They always update on the listen server, but never on the client. I still have no idea what’s wrong.
Edit 1: I have discovered from this question that my material must not be net addressable because it is created at runtime. I get one of these warnings for each card:
LogNetPackageMap:Warning: UPackageMapClient::SupportsObject /Game/UEDPIE_1_level1.level1:PersistentLevel.SCard_145.CardComp1.MaterialInstanceDynamic_415 NOT Supported.Not RF_WasLoaded. NetGUID: <0>
I guess now my question becomes: How do I make my material net addressable? The answer on the other thread was to pass the texture as a parameter via an RPC function. However, the server should be telling the client to update the material, not the other way around. Why would an RPC function work and not a plain old repnotify or a multicast? I am quite confused.
I have a deck of cards where each card has a dynamic material associated with it. The texture of this material changes depending on what card it is, ie. Ace of Spades, 2 of Diamonds, etc. The problem is that the updates to the material are not getting replicated. On the listen server, all the cards look as expected, but the client shows nothing but 2 of Spades, which is the first card in the texture.
I have replicated every relevant variable in the Card class as well as the GameMode class where the deck actually gets created.
My repnotify function looks like this:
void AMyGameMode::UpdateCardMID() {
Deck[CardIndex]->TheMaterialMID->SetScalarParameterValue(FName("Card"), MIDvalue);
}
Deck
, CardIndex
, TheMaterialMID
, and MIDvalue
are all replicated. MIDvalue
(which tells the material the texture coordinates to use) has UPROPERTY(ReplicateUsing = UpdateCardMID)
which I remember to call after MIDvalue
changes.
I’ve also added all these replicated variables to the GetLifetimeReplicatedProps
function in their relevant classes.
The repnotify method is what I’m doing currently. I have also tried multicast replication but that didn’t work either. I could really use some help if anyone has an idea what the problem is.