Problems with replicating dynamic material
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
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:
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:
I've also added all these replicated variables to the
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.
I finally figured this out. First, I was trying to setup the repnotify or the multicast in the GameMode instead of the Card object itself, ie. I was trying to change the card's material within the GameMode instead of the Card. I guess if you want to change an object's material you can't do it outside of the object? In any case, I created a variable inside of the Card object that controls the Scalar Parameter of its dynamic material. This variable is RepNotify. I set this variable in the GameMode, but the repnotify function itself resides within the Card.
Another thing I found by looking at the networking Content Examples, specifically the street light, is that neither the StaticMesh, nor the materials are replicated. I was pretty much replicating everything to make this work, but I found that if the material is replicated, then it actually stopped working.
Not sure if it this was a result of quirks in my own set up or not, but it worked for me.
answered Nov 17 '14 at 01:57 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here