I’m writing this because I can’t find a clear response to my problem.
I want to instantiate object on the server and ignore collision with the owner of that object. So far sounds easy.
The problem for me is that I have an object (with network identity) that its purpose is to create the correct kind of object, lets call it BulletCreator. The client will ask the BulletCreator what kind of bullet must create and the client also tells what player owns it (so the collider can ignores him). This creation request will be via Command and the server should response to the player with bullet-object’s network id or something so the player can refers to it locally.
The questions are:
1- How can I send to the server my playerControllerId and find the player on the Server side?
2- How to send back to the player (because of multiple player on client) a reference to the object spawned on the server? (Sending a message probably but with what data and how to find the object on the client).
Thanks for your help and ask if I should explain myself better.
You can get the ID in the Networkbehaviour script like this: NetworkInstanceId playerId = this.netId;
You can send it then via a command to the server and there you can find the object via: NetworkServer.FindLocalObject(playerId)
Also, while you can’t use FindLocalObject() on the client, you can have the server send the netId of the spawned object to clients and just use FindObjectsOfType(NetworkIdentity) and search for the one that matches the netId.
You can run ClientScene.FindLocalObject instead of NetworkServer.FindLocalObject on the client (just make sure to pick the right function if you’re in a bit of code which runs on both).
If I don’t misunderstand you. Your option is to find all the objects of type NetworkIdentity on the client and then search (iterate) for the matching netId.
But I found this other way:
ClientScene.FindLocalObject(theNetworkId)
And this close my circle
Edit: JirinCrawford posted the same while I was replying