I have a multiplayer FPS where local player character has a flashlight made from a spotlight attached to a cylinder . The Remote Player Prefab also has the same flashlight. The flashlight is controlled by a simple on/off script.
When running the multiplayer test each player can switch on his flashlight and the flashlight projects a beam onto an object when viewed in that players game window. However the other players cannot observe the flashlight or it’s beam.
I don’t really have an in-depth understanding of networked multiplayer games but understand that the other players observe the RemotePlayer Prefab rather than local player. I presume that activating the on/off script on the local player (pressing f) doesn’t affect the RemotePlayer Prefab in the same way (even if it has the same script attached).
How do I get the RemotePlayer Prefab flashlight to reflect the same on/off state as the local player? Is this a role of RPC’s? I have tried placing a NetworkView on the spotlight with no success. Any guidance would be appreciated.
Yes, you need to manually script it either way. It won't automatically watch the state of all public variables- you need to set that up with OnSerializeNetworkView.
– syclamoth