PUN + Standard assets character controller - c#

So, I have 3 scenes a singleplayer scene, a multiplayer scene and a menu scene. When more then one player joins onto the multiplayer scene they both move in the exact same direction. The deafult PUN character controller does not work very well + the tutorial I am using uses the standard assets character controller (which I know is outdated). I think it may be to do with the photon transform view which is nececary for multiplayer wheras in singleplayer without photon transform view/photon view, it works perfectly.
I have tried Changing what is synced but when you exit and reload the prefab nothing has changed.
Please help
Here is a video of my prefab.
https://github.com/JimmyBinoculars/stack/blob/main/2022-12-04%2010-40-33.mkv

Related

Errors in Oculus Controller Movement Configuration Scripts

We are working on a VR Driving project using Oculus controllers. We are stuck on a bit wherein we are tryin to move the car forward and backward using the controllers. The camera view is set to be inside the car, but when we try to move the car faster, the camera view moves out of the car.
In addition to this, when we turn left or right and try to move forward, the car seems to move sideways but not in the direction to which we turn towards. Kindly help us on wit this issue.
The Unity version that in use is 2021.3.11
we wanted the player to drive the car smoothly but as soon as the speed is increased the camera tends to jump out of the car.

Unity NavMeshAgents snap to outskirts of NavMeshSurface during runtime

I'm having some interesting behaviour with NavMeshAgents. So I've been working on a project for the past few months which is revolving around creating believable enemy AI systems for stealth games. When the player kills an enemy they can pickup the body and put it into a body bag, this all worked well and fine for a while but now once the player has picked up two corpses all Nav Agents do this.
They are still in their patrol state (using a behaviour tree) and all of the AI have a destination set which can be seen on the debug tools for the Agent. However if I try to move the AI whether that being dragging them around or setting a position through the inspector they will snap back to a corner of the NavMeshSurface.
Using Unity 2021.1.17f1 and using the latest compatible version of the NavMeshComponents package provided by Unity.
Things I've tried:
Changing Radius and Height of agents
Setting the floor and such as navigation static objects
Removing the NavMeshComponents package scripts and replacing them with the original NavMesh system. Didn't work and took a lot longer to build the NavMesh
Interesting behaviour:
The amount of body bags the player has to pick up seems to be related to how many AI are in the scene. For example currently there are 23 AI and it takes two body bags for this glitch to happen, but if there are 24 to 31 AI in the scene then it requires three body bags to be picked up for it to happen.
All calls to the NavMeshAgent are done through a AILocomotion script which handles enabling and disabling rotation, movement and updating the animation. Movement is only disabled upon death or when the AI is in the wait state, other than that every Move based state re-eneables movement.
Update: Found the solution
It turns out Unity does not like it when you destroy a NavMeshAgent component during runtime. Now when the player picks up a corpse it leaves the NavAgent behind but destroys the mesh and colliders etc.

Real time sync in Unity using Photon Unity Network(multiplayer)

Im working on a demo project, where I use Unity 3D and Photon Unity network(PUN) for a real time game.
The person in the top panel is an enemy unit, controlled by another player who does damage to the player on the bottom left (1/3 hp left).
However, the person on the bottom right is a healer who can heal the bottom left player (both controlled by the local player).
Here's my problem! Since it isn't turn based and has to happen real time. How do I design my multiplayer system? Ive previously worked on turn based games, where I just pass the indices and mirror the events taking place locally, in the remote player as well.
But here with latency in the picture, I do not know how to proceed!
What I would like to do is, have the healer heal the player locally as well on the remote player's phone before he is attacked by the remote player or kill the player before the healer can heal his hp depending on the timestamp in which the events happen and reflect such on both the devices.
I think you are confused with some of the pun networking features.
If the healer heals your local player, so will be the remote instances of your local player. Your healing system must be networked of course, make sure you go through our basic tutorial to learn how to implement a simple health system.
https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/player-networking#health_synchronization
What will be slightly more complex than health management is the switch between your player and healer locally. for this you have two main variants.
transfer ownership between the player and healer: https://doc.photonengine.com/en-us/pun/v1/demos-and-tutorials/package-demos/ownership-transfer (this is a v1 demo but the principle still applies to v2)
have a invisible network player, and using your own logic in your game, have the player matching this invisible network player or the healer matching it.

Unity character assets don't work in multiplayer

I'm creating an fps game and I want to have multiplayer. I use the standard character assets from unity but when I join my server with more than two players dey cant see the other player move and when they move both players move. It's like the player move script is run on both players at the same time. So if I press w on own of the clients both players move. I'm coding in c#. no error message but in the console it spams "There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene."
standard character assets from unity
player network Identity
Network Manager
You're instantiating a controlled player every time someone joins the server. If they have the same controller components, both of the objects are going to react to controls. Create a non-controllable player prefab and have it react to messages sent from the other clients.
If you have a movement component separate from your controller component, you can reuse the movement component on the non-controllable object.

Unity networking without a player prefab (C#)

I would like to add multiplayer to my game. I use UMA (https://www.assetstore.unity3d.com/en/#!/content/13930) to generate a character in a character creation scene. I then use:
DontDestroyOnLoad(characterController);
To take the player to my main game scene. The UMA generated player cannot be made a prefab, cannot be duplicated or instantiated (not sure why but it doesn't work). So I then via script move the player to the spawn position where they can play the game.
I have made multiplayer games before, but in all of them I use
Network.Instantiate(playerPrefab);
to add the player to the game. The problem here is that I have no idea (nor could I find out online) how to implement multiplayer with a character ALREADY in the scene.
Any help, ideas, advice or suggestions would help me out a lot!
You can instantiate only the GameObject that has the scripts to control the player and search for the models generated by UMA which are already in the scene.
By the way, if you're using Unity 5.1 or newer Network.Instantiate is not used anymore. http://docs.unity3d.com/Manual/net-NetworkInstantiate.html

Categories