- Home /
Network.Instantiate Problem. AI not behaving the same on all clients.
So I network.instantiate a prefab of an enemy with AI.
The AI reacts differently on both computers I am testing it on only attacking the player who's client it is. I am adding a network.Destroy to get rid of the monsters when either player kills one.
So my question is: Should I make an array in the AI to detect all players on the field and only attack the closest one? or is this another problem which involves the network tracking movement?
Answer by Loius · Oct 30, 2012 at 06:02 PM
Well, if your code only checks against the local player, then your ai is only going to attack the local player. If you want it to attack the closest player, then yes, you should write a quick snippet to locate the closest player before going after them.
So I wrote the code to find the closets player, and I did so using FindWithTag and a small algorithm to check who is the closest. This doesn't seem to work as the enemies now do this weird thing where they split off between the two players where one player can see 1 and the other can see the other but there are 2 which can damage both players. This obviously has something to do with Network View. What do you think? Do I have to sync the scripts AND the objects of the enemies over the network with network view modules?
Your answer
Follow this Question
Related Questions
Load Previously Instantiated Network Objects 1 Answer
How do i access a network instantiated object? 1 Answer
Failure generating network code 1 Answer
Instantiate By ID? 0 Answers
Network rigidbody synchronize 0 Answers