Hi there. I basicly try to call a function in C++ which does the exactly same as this Blueprint does:
(It should set the color of a cube on the clientside to green and on the serverside to red)
My problem is, that I need to call this function from a C++ script, which is called only on the server. In a second step I need to get a specific component and set a Value. Unfortunately I failed at both of these steps.
I spent hours trying out different ways to achieve it, but it just won’t work. I could really need some help!
How to call the function on the server and the client:
You can use replicated variables which trigger a RepNotify-Function/Event. It’s explained here: RepNotify
How to access a StaticMeshComponent:
A StaticMeshComponent won’t show up in the defaults, but it will be accessible in the Blueprint. To link the component, you have to simply set the connection in the construction-graph.
This might work for you, but you should be aware of the differences between replication and rpcs. RPCs should be used for gameplay important things. Replicated variables aren’t guaranteed to be replicated to clients within a reasonable timeframe or in any specific order, only that given enough time they should update on the client.
You should still look into why RPCs were not working for you, because if they weren’t it’s probably symptomatic of a larger issue.