- Home /
I didnt get a good answer to my question, i have asked around on a couple of other places and still no answer. I have since moved on
How do I Assign client authority to a gameobject?
How do I if some variable returns true, give client authority or is it at all possible? I know that it is possible to spawn a object with client authority (https://docs.unity3d.com/ScriptReference/Networking.NetworkServer.SpawnWithClientAuthority.html), but that doesn't help here. The object i want to assign authority to is a object that you can shoot and i want to destroy the object afterwards, but this isn't possible if the client is the one to shoot the object. I think the answer may lay in (https://docs.unity3d.com/ScriptReference/Networking.NetworkIdentity.AssignClientAuthority.html) but im not sure how to use it.
Answer by adipatil3517 · May 16, 2017 at 05:08 AM
Add network identity to player then check the Local Player Authority in network identity then in script check condition if(isLocalPlayer) { .... // here goes your shooting code} . also do not forget to add using UnityEngine.Networking ; and Instead of MonoBehaviour use NetworkBehaviour then you will get player on server and "isLocalPlayer " will check that player is Local or not and if it is Local it will shoot the object
Hi, I am trying to do this. What you have suggested I have already tried and does not work for me :(
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
[UNET] Only spawn certain server objects on local client? 0 Answers
C# How to have a toggle 1 Answer