Hi! I'm trying to add a NetworkView component to an object at runtime. Let me give you some background first: I'm trying to share a camera's transform across the network. In order to do that, I created a prefab that contains a camera (and which doesn't own a NetworkView component), instantiate it with Network.Instantiate and add a NetworkView component at runtime. Here's the code:
The code above compiles and executes fine, but it's not doing what I expect it to do (i.e., when running in networked mode, the camera's transform doesn't get transferred across to the other hosts). Notice that assigning a NetworkView component to the prefab in the editor and instantiating the prefab using Network.Instantiate works fine, but I really need to do it by code.
Do you have any suggestions? Thanks in advance for your input!
I finally solved it! The problem was that I wasn't adding the NetworkView component inside an RPC. I made a few changes and now everything's working OK.
answered Apr 08 '11 at 02:35 PM