Pun multiplayer + Pseudo 3d

SirRingo

Member
I made a pun multiplayer scene using the pun add on - it worked great !!
made it pseudo 3d and used 2 scripts in order for the players to follow the path (added them here).
Everything works well actually, beside one problem: the players aim only in one direction - Front.
allthough the players can see the rifle turning and aiming towards the mouse, the OTHER PLAYERS wont get that input and see that player constantly aiming front. and the projectiles will actually go only to the front of the player. they wont ACTUALLY aim in the right direction. any idea why ? is there something in the code preventing the players from sending out their aiming vector ?

this script on the players prefabs:

using Opsive.UltimateCharacterController.Character;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InitHunter : MonoBehaviour
{
void Start()
{
var ultimateCharacterLocomotion = GetComponent<UltimateCharacterLocomotion>();
if (null == ultimateCharacterLocomotion)
{
Debug.LogError("Unable to get character locomotion");
return;
}
PathController.Instance.SetPath(ultimateCharacterLocomotion);
}
}

and this one on the gameobject with the path:

using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Motion;
using Opsive.UltimateCharacterController.ThirdPersonController.Character.MovementTypes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PathController : MonoBehaviour
{
public static PathController Instance { get; set; }

private Path _path;

protected void Awake()
{
Instance = this;
_path = GetComponent<Path>();
}

void Start()
{

}
 

Justin

Administrator
Staff member
This will take some debugging. The rotation is retrieved within PunCharacterTransformMonitor.OnPhotonSerializeView. Is the TransformDirtyFlags set correctly so the m_NetworkRotation variable updates correctly?
 

SirRingo

Member
well - it looks fine, as far as we could tell. we haven't touched it - and it DOES WORK perfect with OTHER movement types.

it seems like the pun add on Does not support the Pseudo 3d. the PunCharecterTransformMonitor dose not seem to handle what happens when the movement type forces the Transform in the Path direction. it looses the value of where character is Looking.

we tried disabling these new scripts we added - and the outcome was the SAME. yes the character didn't stick to a path and could be located on different Z location - but never the less - the rotation did not sync to the pun.

any idea how to fix this ?
 

SirRingo

Member
Dear Justin,
Thank you for your response. We tried but still could not figure out the solution for this issue.

The next picture clarifies our problem better:

3.jpg

Two players are playing multiplayer mode - the location of the two entities is well synchronized but their aiming is incorrect on the remote player.


1. Do the current PUN scripts provide support for solution of the above problem, or do we need to extend them / write our own script for that?
2. The aiming of each hero is determined by the "Fire Point" gameobject. We tried adding that gameobject transform as a new Observed Component to the PhotonView script that exists on each hero:

2020-05-22_14h03_06.png

but that did not work either.

Your help is highly appreciated, please provide us some guidelines for tackling this problem.

Thank you,
Elad
 

Justin

Administrator
Staff member
The aiming is controlled by the PUN add-on. This is sent by the PunLookSource - within OnPhotonSerializeView it should be sending the m_NetworkLookDirection which is the direction that the character is aiming. Is this value correct?

Code:
                    PunUtility.SendCompressedVector3(stream, m_NetworkLookDirection);
 

SirRingo

Member
We Think the route of the problem IS in the Dirty Flags - like you suggested.

Where and how can I change the flags/ dirty flags ? is there some place I am missing I can do this without messing with the code ?
if not - is there any script effecting the flags other than pun look source ?
sorry. couldn't find any documentation
 

Justin

Administrator
Staff member
You shouldn't need to modify the dirty flags. Is m_NetworkLookDirection staying constant? m_NetworkLookDirection should be set to the direction that the character is looking.
 

SirRingo

Member
hey Justin - Thanks a lot for your help so far.

The aiming is controlled by the PUN add-on. This is sent by the PunLookSource - within OnPhotonSerializeView it should be sending the m_NetworkLookDirection which is the direction that the character is aiming. Is this value correct?

Code:
                    PunUtility.SendCompressedVector3(stream, m_NetworkLookDirection);

NO- the value is not correct. we made a very simple scene with nothing in it but a plane and the pun charecters which are being loaded - we could see that with 3rdPerson movment type (ADVENTURE) all is good and we can see the values go up and down - while with Psuedo - the value for rotation steaks to 0.0

you can also see it clearly in the null exeption, while in Psuedo:
2020-05-29_22h03_56.png
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.PunObjectPool.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/PunObjectPool.cs:214)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3002)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotNet/PeerBase.cs:663)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotNet/EnetPeer.cs:545)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotNet/PhotonPeer.cs:1759)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:205)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:139)

THIS MESSAGE IS NOT SEEN WHILE IN ADVENTURE MODE !! only PSEUDO

WHAT WE ARE CLEARLY SEEING in pseudo - is that first player to connect (the one who calls the shots) is sending it's projectiles in the right direction - although his body (head and gun) are not pointing in the right direction.
the second player's projectiles are not being sent in the right direction - only straight. (and the turning of the head of course is the same problem

the problem comes out of the box the moment you put pseudo 3d on the player. I double and triple checked it. no problem to to reproduce.
 
Last edited:

Justin

Administrator
Staff member
What is the very first error that you are receiving? That error indicates that it can't find the object being destroyed which doesn't relate to the movement type. As a test I just set the demo scene character to use the Pseudo2D movement type and that part worked.
 

SirRingo

Member
first computer (UnityStation01) to log in the scene gets this:
2020-06-01_17h11_27.png

then the second computer (Another Unity Station) to log in the same scene as a second player gets this:
2020-06-01_17h12_18.png
2020-06-01_17h12_40.png
 

SirRingo

Member
I just set the demo scene character to use the Pseudo2D movement type and that part worked.
is it not following a path ? is there any other set up i can do with out using a path at all ? maybe without those scripts- the ones I wrote above - maybe they are the source of the problem ?

my problem is only seen properly when a second user logs in
 

Justin

Administrator
Staff member
Getting an error within the PunStateManager will definitely cause later problems. Line 63 points to:

Code:
            stateManager.SendStateChangeEvent = true;

So the stateManager object doesn't exist. Did you add the State Manager through the Setup Manager?
 

SirRingo

Member
I didn't add anything like that manually - I cant see anywhere to do so in the setup - character manager - I can see it in the scene on the Game + On the PunGame: (Charecters dont have any)

2020-06-02_15h20_15.png
should I enable SendState ?
2020-06-02_15h22_23.png
 
Top