At the moment I have an issue where I need to find the closest game object with the tag “Player”
These player game objects are prefabs
I have a function below. When I Debug variable gos it returns UnityEngine.GameObject[ ]
Which I assume that means empty.
But yet the function returns a player game object still.
Is it not possible to read tags from prefabs loaded into the scene?
thanks for the response toreau
When I do Debug.Log (gos.Length);
It does say there are 2.
Isn’t there a way to show the array as in printing it in log?
So I guess it is finding all Players then.
The problem is its not finding the closest ones
so i’ll debug that then. Its quite interesting though cause this function was taken right out of the unith3d manual
I’m not sure how its even compiling but you seem to be missing a closing brace }
for the foreach clause. This code will always return the first go in gos i.e the foreach
is running only once. So you need to put a closing brace } before the return closest;
line.
thanks for the response Game boy
so apparently all versions of the function work. Sitting here trying to problem solve this for over 6 hours.
I realize my issue is that the enemy mobs are not updating their location to the other players.
OnPhotonSerializeView is doing nothing right now. I have no idea why
I even put Debug.Log(“test”); inside of it and it never logs
I use this function also when putting players in sync and it works but I also put Debug.Log(“test”) on that one to and it also doesn’t log.
If I drag the enemies transform into their own photoview then everything works except enemies are all jaggy looking
so the question is how do I keep AI enemies in sync with all the other human players
Should I even be trying to sync all the enemy AI continuously like that?
I’m trying to make a game where you have up to 6 people in a group going around killing stuff.
Just 6 people to a networking instance.