- Home /
Simple networked AI works if only one, but freaks out client-side if more than one
I've been banging my head against a wall for a few hours now, and cannot for the life of me figure out why this won't work.
I have a networked AI that works fine when there is only one, but when I add two, they freak out on the client side.
All the AI does is move around randomly, its a wandering script. I'm trying to do it authoritatively, so all the wandering code is only run on the server ( if (Network.isServer){ ). The AI object is a rigidbody, so I'm using a network view that is observing NetworkRigidbody, from the networking example on the Unity docs. However, I also tried RPC'ing the position/rotation updates to all clients in Update() on the AI script (the code in Update() to send the RPC if the position or rotation changed was also only run on the server).
Anyone have any ideas why this is not working?
This isn't really an answer but; make sure you are not using global state that you might mess up with, or that you do something like GameObject.Find("AI") if both are called AI. What do you mean happens when you say the AI "freaks out"? For all I can see, it could just beed Debug.Log("Frrrrreaaak"); :)
Does the AI work when playing offline while having two of them?
I'm not doing anything with global states, as far as I can tell. When I say freak out, I mean they bounce all over the place, spaz, and one of them doesnt move at all.
Yes, it works when played offline, or as just a server with no clients.
I tried switching the spawning from RPC's to Network.Instantiate, and the Enemies actually work fine now, except they all spawn as soon as a player connects, completely ignoring the code on the spawner that calculates the distances between the spawners and the players before spawning anything (they should only get instantiated if an object tagged player gets within a certain distance of the spawner, in the server's instance of the game).
Answer by EliteUnity3D · Mar 09, 2013 at 03:30 AM
@Prime, can you tell me how you got your AI enemy to detect you presense online?
Your answer
Follow this Question
Related Questions
How would I continue an object's movement in the same direction as per last user input? 1 Answer
How can I make a smooth movement for sync transform 0 Answers
One user controls all of them on network 1 Answer
Trying to make AI travel (and face) a waypoint 0 Answers
AI movement bug ("teleporting" after certain Platforms) 0 Answers