- Home /
RPC - Transform not Supported?
I'm working on a spawn script for my network game, and I need my RPC to respawn a dead player to all the clients. But I can't have a that 'dead players' transform as a parameter, so how else would I uniquely identify the dead player in the RPC, to be able to spawn him?
I hope this simple question has a simple answer :/
Thanks again,
Ollie
Answer by whydoidoit · May 23, 2012 at 10:02 PM
You can't send the transform but you can send the position and the rotation - RPC supports Vector3 and Quaternion.
You can use the networkViewID to identify the character or if that isn't working you could create a unique identifier as a string.
A good way of doing that is to use a Guid and turn it into a string:
public string id = Guid.NewGuid().ToString();
You will need to import the System namespace to access Guid
Is there another form of identity for RPC? Also, inside my RPC, lets say I have Destroy(gameObject), is that gameObject referring to the object the RPC is actively on, or all the gameObjects that the RPC will be sent to?
Inside the RPC call that will run on every object that receives the call - so if you do an All or Others then it will run for that particular instance on all of the other games.
Rather than destroying the GameObject you could always just put it into hibernation until it respawns....
But it will only happen for the viewID that you specify - so that will be that particular instance on all players computers - not all gameobjects of that type. Ugh my English is failing me :) Told you it was $$anonymous$$d bending...
How would one specify an object via networkViewID? Eg: (networkID).gameObject.enable = false
On a particular computer or everywhere? BTW gameObject doesn't have an .enable - but components do. GameObject has the whole setActiveRecursively() and active stuff.
If you mean everywhere then you can call NetworkView.Find(ID) and then RPC that with a call to something that will set the active status or disable/enable the renderer
Your answer
