![]() ![]() Strange behaviour may occur UnityEngine.NetworkView:Find(NetworkViewID) PlayerStats:SetPlayersEnergy(Int32) (at Assets/Scripts/Player/PlayerStats. View ID AllocatedID: 1 not found during lookup. When I use the exact same code on a different function to add energy I always get this error: The problem is so strange that in one function I go through the hashtable without any error and remove their energy. I have some functions that go through all the players, stored in a hashtable, which take or add energy to them. ![]() I am creating a multi player game where the server keeps track of all players and their health. Sorry for wall of text.I have been battling with this error for some time now and I really can't find the source of its problem. It doesnt matter if the NetworkView is being used for something else or just for the RPC function. A NetworkView must be attached to the GameObject where the RPC function is being called. The called function must have the RPC tag set ( RPC for C Sharp code). Is this a proper way to differentiate control over a server and client? This will be a strictly 2-player co-op, so my code is looking like it'll have to revolve around server player and client player. Call a RPC function on all connected peers. I've had a case in the past where a scene NetworkView was getting changed into a non-scene NetworkView at runtime, for some reason, and it led to errors like this. ![]() It's looking for a network view with a 'Scene' ID of 1. Thanks to that, I just do a check like above, except with failing conditions, wherein I delete all the cameras, which has seemingly worked like a charm. Look in the editor while the game is running and check that the ID is correct at runtime. Like, when the client joins the server, the server's Start() code on their already instantiated object runs, and then the client that joined and instantiated has his run. I'm not sure if this is intentional, but using Network.Instantiate() apparently queues up Start() code that is run. However, I just want to make sure this is a smart way to do it. UGH.ĮDIT3: Got it working properly, cameras removed and all, for the first time. It feels the like the server instance has control as a client as well as a server, and I don't know how to resolve that. If you'd rather link me to something specific to answer my stupid questions, feel free.ĮDIT: So after testing a bit, is it just separated by IP? So the IP address that calls Network.InitializeServer() is known as the "server", and anyone who connects to said IP is a "client"? In that case, if I'm setting it up for one player to host and another to join, how do I differentiate them? Just using NetworkPeerType checks?ĮDIT2: I tried setting up control using this code:Īnd it properly recognized which instance was a client and which was the server, but I still had the issue where when the client joined, they assumed each other's control. This whole networking business is new and scary to me, and I guess I'm still not 100% on how ownership and such works. If I start a server using this item, does that make that GameObject the server "owner"? So I'd have to use Network.Instantiate() with another GameObject to have it treated as a player? blockSprites.RemoveAll (s > s null) Share. So you can use List.RemoveAll () to remove all the elements that compare as equal to null.In my case, I have the code from the unity tutorial that uses simple GUI to connect to or start a server. Once a game object has been destroyed, it will compare as equal to null. Is it simply on which items the code is attached to? I guess I'm not sure how to differentiate between the server and client doing it when I'm having a client host as well as play. I see what you're saying, and apologize for my lack of an answer. I'm actively working on this again, so forgive me if I figure it out soon. ![]()
0 Comments
Leave a Reply. |