Hello, I’ve tried to make NavMesh agent be grabbed in the OnStartAuthority method with GetComponent() instead of serialized field, but when I do it like that, host works normally, but client crashes instantly and says that the navmesh agent is null. Why is this happening and can I somehow make GetComponent() work?
I found out right after asking, I tried to get NavMeshAgent in the OnStartAuthority, which is called only in the client, but the Command method is ran on the server, which isn’t syncing the NavMeshAgent, so I either need to call GetComponent in Awake, so it’s in both server and client, or in OnStartServer.
OnStartAuthority should be called on components that are only needed on the client, Awake on components that are needed everywhere and OnStartServer on components that are only needed in the server.
1 Like
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.