Loading objcts At Runtime visible to network

Hell Unityrs,

I have this problem: I am developing a website…using the webplayer and I load a model at Runtime.
I got everything in place already for the Network connection, and I followed the multiplayer tutorial on Unity3D website. So, when I load an OBJ object which is derivided from GrameObject, I create a new obj:

function wwwLoadObjects(addrs: String) {
var obj = new OBJ();
//StartCoroutine(obj.Load(addrs));

obj.transform.position = Vector3(0,0,0); //Positioning the object in (0,0,0);
obj.AddComponent(“NetworkView”); //Enalbles the new object to be linked
StartCoroutine(obj.Load(filename));
}

but for some reason If I open one browser I can see the model, but If I open a new window for the client, I can’t see the model. What am I missing?

Many thanks!.
GC.

did you also set the NetworkStateSynchronization to ReliableDeltaCompressed ?

Yes, I changed it in this way: Should I call the Network.Instantiate somewhere? I don’t quite get in which way. :frowning:

function wwwLoadObjects(addrs: String) {
var obj = new OBJ();
//var TObj :Transform;

StartCoroutine(obj.Load(addrs));

obj.transform.position = Vector3(0,0,0); //Positioning the object in (0,0,0);
obj.AddComponent(NetworkView); //Enalbles the new object to be linked
obj.GetComponent(NetworkView).stateSynchronization = NetworkStateSynchronization.ReliableDeltaCompressed;
TObj = obj.transform;
//Network.Instantiate(TObj, obj.transform.position, obj.transform.rotation,0);
}

yes you need to call network.instantiate

Thanks, but still there is something i miss I believe… the log file for the webplayer has these messages:
View ID AllocatedID: 0 not found during lookup. Strange behaviour may occur

and

Received state update for view id’ AllocatedID: 0’ but the NetworkView doesn’t exist.

Ok, this is a new version:
apparently it works, the problem I have is that in the server window everything is fine, in the client window, pre-allocated objects in the scene collide with the uploaded object which for some reason is not rendered :frowning: but it interacts with the other objects.

Function wwwLoadObject(addrs: String) {
var obj = new OBJ();
StartCoroutine(obj.Load(addrs));
Debug.Log( "OBJ: " + obj);
Debug.Log(“wwwLoadObjects”);

obj.transform.position = Vector3(0,5,0); //Positioning the object in (0,0,0);
obj.AddComponent(NetworkView); //Enalbles the new object to be linked
obj.GetComponent(NetworkView).stateSynchronization = NetworkStateSynchronization.ReliableDeltaCompressed;
obj.AddComponent(BoxCollider);
obj.AddComponent(Rigidbody);

Debug.Log(“---- NETWORK ID:”);
Debug.Log(“----” + obj.GetComponent(NetworkView).viewID);
TObj = obj.transform;
Network.Instantiate(TObj, obj.transform.position, obj.transform.rotation,3);
Debug.Log(“------ AFTER NETWORK INSTANTIATE”);
Debug.Log(“wwwLOADEDOBJECT”);

do you load in your model on all clients or only on one ? you need to load it to all clients for them to be able to see it.

Well… my web page as a button, which sent the link to the OBJ model to load. The UnityObject in the webplayer, detects the link, load the object in the webplayer…so regardless who loads the object (client or server), it appears in only one webplayer, the one which uploaded the object, but of course I would need that object be visible in all the webplayers open.

I thought that the NetworkView attached to the model could make the trick. :frowning:

all clients need to load it also, thats why you have interaction and no render, the nview sends the transform but the rendering is done on each client. all clients need the model to be able to render it.

Hi,

would it be this message a sign of that problem:
Received state update for view id’ AllocatedID: 0’ but the NetworkView doesn’t exist

as I get this only when a client connects.

yes, the nview needs to exist on all clients attached to the model.

Right… mmm so I guess I have to go deeper in the multyplayer tutorial on Unity and see where that happens. And doing the same thing hopefully on the uploaded object.

depending on the network model you are using, the client can send an rpc call to all other clients telling them to also load the model and instantiate it.
Or you can send a call to the server who then tells all clients to load the model.

Cool,

well I guess that as any client has the possiblity to load a model, the best way is letting him to detects all the clients connected and send them the link to the gameobject so to update their scene (I hope).

Thanks!
GC

May be I can transform the LoadObject function in an RPC function …

yes, thats a way to do it.
make an rpc function which loads and instantiates the model, then broadcast the rpc to the world.
all clients will pick up the rpc and load the model
no more need to network.instantiate at that time.

Groovy, super thanks! I’m pretty new to this stuff… and I just need to make that very clear otherwise I have to change it all the time.

I own you a beer! or may be 100 :slight_smile:
Finally I managed to render the object in any client window… although now, the object doesn’t fall with the gravity anymore, but I can see it in the clients/server window.

Cheers!
Giancarlo