Does Deathmatch work with PUN?

If there are hierarchy AI objects that are either disabled or enabled from the other Game but can't be seen, then you need to figure out why they are not visible.

Are they disabled? Have incorrect skin settings? InvisibleShadowCaster/PerspectiveMonitor settings making the skin invisible? Are they at some far away transform?
No, the AI objects aren't disabled. They have the incorrect skin settings applied, I think based off team and if they are spawned from the master or remote client. The transforms are fine and within the boundaries of the NavMesh.
What is your scene set up? Are you using one of the Demo scenes to create this? I would advise against this because particularly with Deathmatch AI kit there are other things which may affect spawning and such.

My scene is a pretty simple setup that I have run through the Opsive tools for setting the layers, managers, camera and everything else. I have also run the scene through the Pun Addon scene setup tool.

I would advise creating your own Launcher and Room creation script leading in to a simple scene that only has the basics - PunGame and what ever other components handle the Pun Spawning.
I do have my own launcher and room creation scene as well where the players (up to 4) join a room and start a game. Right now, the AI is spawned for each player, not just the master which I think is part of the problem. I have run my character prefabs through the character and the pun Addon also so they are set up correctly now as well. After I added the transform monitor component, I added the others so the Addon didn't really do anything else I don't think besides set the layers up, I'm probably really wrong about that though. :)
 
No, the AI objects aren't disabled. They have the incorrect skin settings applied, I think based off team and if they are spawned from the master or remote client. The transforms are fine and within the boundaries of the NavMesh.


My scene is a pretty simple setup that I have run through the Opsive tools for setting the layers, managers, camera and everything else. I have also run the scene through the Pun Addon scene setup tool.


I do have my own launcher and room creation scene as well where the players (up to 4) join a room and start a game. Right now, the AI is spawned for each player, not just the master which I think is part of the problem. I have run my character prefabs through the character and the pun Addon also so they are set up correctly now as well. After I added the transform monitor component, I added the others so the Addon didn't really do anything else I don't think besides set the layers up, I'm probably really wrong about that though. :)
So how it should work is usually only the master should spawn the AI, ideally using PhotonNetwork.instantiate


This will mean any client currently in the room and future joiners will automatically spawn from resource pool the same object. So all photonview and ID stuff should fall into place

You should remove the remote client's ability to spawn the ai by running a master check perhaps.
 
I am now checking to see if the local player is the master and if it is, spawn the AI, if not don't. This helps by not spawning two versions of the AI. The only problem I have with this right now is that once the master leaves the room, so does the AI. I'll work on that after I get it working. I'm thinking the AI needs to be spawned with .InstantiateRoomObject instead. I am still having a problem with the AI being properly synched. On the master, everything looks good. Animations, team colors, etc. On the remote client however is where it gets interesting.

Now with one version of the AI, they are synched position and animation wise, but that is about it...until the AI object has respawned once. What I'm seeing is on the remote client, the AI object will be attacking, using the proper animation, but not holding the rifle, even though the animation shows he should be holding the rifle. The AI are all blue, the default prefab color. The sounds play, and throws grenades also.

After the AI object has respawned, the behavior is normal with the exception of the skin colors.


I know where this is being set and all that, what I'm wondering is if there is a callback or event I can handle that when the remote client joins in, and the AI is spawned on there, I can set up the object like it does for the master. Set the colors up, set the behavior tree up, etc.
 
After some sleep, and some more reading on PhotonNetwork.Instantiate, I don't think handling an event is going to work either. How does the AI know what team it's on? As far as I can tell, it doesn't know so if I handled the event on the client, I wouldn't be able to tell it what color to make it since that isn't part of the object. Do I need to do manual instantiation so I can manually create an event that has all the appropriate data in it so that when a client joins later, and the stored event on the server fires, the AI know what team, and therefore what color they should be? This would be similar to the way SpawnManagerBase is working, I think.

What I'm curious about, is why the AI work correctly on the remote client after being respawned. The team color isn't right, but the behavior is, along with the animations.
 
I am now checking to see if the local player is the master and if it is, spawn the AI, if not don't. This helps by not spawning two versions of the AI. The only problem I have with this right now is that once the master leaves the room, so does the AI. I'll work on that after I get it working. I'm thinking the AI needs to be spawned with .InstantiateRoomObject instead. I am still having a problem with the AI being properly synched. On the master, everything looks good. Animations, team colors, etc. On the remote client however is where it gets interesting.
Yes you're correct, I just checked my spawner, this is what I used 1650854783451.png
 
I am now checking to see if the local player is the master and if it is, spawn the AI, if not don't. This helps by not spawning two versions of the AI. The only problem I have with this right now is that once the master leaves the room, so does the AI. I'll work on that after I get it working. I'm thinking the AI needs to be spawned with .InstantiateRoomObject instead. I am still having a problem with the AI being properly synched. On the master, everything looks good. Animations, team colors, etc. On the remote client however is where it gets interesting.

Now with one version of the AI, they are synched position and animation wise, but that is about it...until the AI object has respawned once. What I'm seeing is on the remote client, the AI object will be attacking, using the proper animation, but not holding the rifle, even though the animation shows he should be holding the rifle. The AI are all blue, the default prefab color. The sounds play, and throws grenades also.

After the AI object has respawned, the behavior is normal with the exception of the skin colors.


I know where this is being set and all that, what I'm wondering is if there is a callback or event I can handle that when the remote client joins in, and the AI is spawned on there, I can set up the object like it does for the master. Set the colors up, set the behavior tree up, etc.
Definitely you can. I have an absolutely enormous process that occurs when a new client joins, which involves the new client sending the entire list of character variables they have set, to every player. Then each machine updates the skin choices and any attachments/armour/cosmetics etc.

Call back is something along the lines of 'OnPlayerJoinedRoom' (I can't remember the syntax)
 
After some sleep, and some more reading on PhotonNetwork.Instantiate, I don't think handling an event is going to work either. How does the AI know what team it's on? As far as I can tell, it doesn't know so if I handled the event on the client, I wouldn't be able to tell it what color to make it since that isn't part of the object. Do I need to do manual instantiation so I can manually create an event that has all the appropriate data in it so that when a client joins later, and the stored event on the server fires, the AI know what team, and therefore what color they should be? This would be similar to the way SpawnManagerBase is working, I think.

What I'm curious about, is why the AI work correctly on the remote client after being respawned. The team color isn't right, but the behavior is, along with the animations.
I would personally at first attempt to perform the InstantiateRoomObject first, however upon sending that follow up with an RPC message to all other clients with the required team information and perhaps a reference to the spawned object, then each machine can apply the correct settings.
 
Also, just wanted to ask whether you are actually creating a Deathmatch based game?

If you are not then I wouldn't be using the Deathmatch aspects like team colours and such.

Just the layers for determining who are enemies to whom.
 
I created a data object that contains some setup data and then use the OnPhotonInstantiate to get this data when the AI is instantiated. I have the colors working now, but not the rifle part. The AI are playing the proper animation, but just not holding the rifle until after they have respawned exactly once.

Part of the setup data includes the color, and enemy and friendly layers. That's really all I'm setting at the moment. I am really wondering why the AI work correctly after being respawned but not from the beginning. I have used the inspector to enable the rifle on an AI that doesn't have one with no change. The animation is right, IK is right, etc, just no actual firing of the rifle until after a respawn.
 
Part of the setup data includes the color, and enemy and friendly layers. That's really all I'm setting at the moment. I am really wondering why the AI work correctly after being respawned but not from the beginning. I have used the inspector to enable the rifle on an AI that doesn't have one with no change. The animation is right, IK is right, etc, just no actual firing of the rifle until after a respawn.
There are plenty of opportunities for word issues like that, unfortunately I'm not great at fixing those.

sounds like some initialisation missing from the initial spawn that is corrected on respawn but I don't know what. Sorry can't help with that part.
 
I now have it all working as I want it I think. The skin material colors are working correctly, the animations are there along with the weapons and behavior. I made the AI room objects so that when the master leaves the room, the AI doesn't disappear.

I ended up creating a new class to set up the AI upon instantiation and handling the OnPhotonInstantiate event for the AI objects. Then invoke a couple RPC methods and I think that is it. There is some small config things here and there, but basically it is just a normal Pun object.

Thanks for the help. Always helps to have someone else provide some insight.
 
Last edited:
Top