Sync position different between two players

Options
Hi guys!
We are trying to make a game like Clash Royal, 1vs1 RTS, but with a different strategy.
We are getting more problem when we try to sync the position of the player units and enemy units over the Photon Network.
We think the Clash Royal map is fixed, Player A and Player B see always the same sprites of the map, but, only the position of the units spawned are inverted ( Reflection/Mirror ).

The script we have made have now one problem. The "cuboProva" instantiate sync their position over the photon network but, always, it go on the position (0,0,0). That because in the code there are: Vector3.zero, but we want, for example if we change the position on the unity scene, the object sync their position even the client connected.

How we can fix that problem and make the reflection of the spawn unit?

CODE:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class syncCubo : Photon.MonoBehaviour {
Vector3 realPosition = Vector3.zero;

void Update()
{
if (photonView.isMine)
{

}
else
{
transform.position = Vector3.Lerp(transform.position, this.realPosition, 0.1f);
}
}

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
stream.SendNext(transform.position);
}
else
{
this.realPosition = (Vector3)stream.ReceiveNext();
}
}
}

Comments

  • Minds
    Options
    Minds said:

    Hi guys!
    We are trying to make a game like Clash Royal, 1vs1 RTS, but with a different strategy.
    We are getting more problem when we try to sync the position of the player units and enemy units over the Photon Network.
    We think the Clash Royal map is fixed, Player A and Player B see always the same sprites of the map, but, only the position of the units spawned are inverted ( Reflection/Mirror ).

    The script we have made have now one problem. The "cuboProva" instantiate sync their position over the photon network but, always, it go on the position (0,0,0). That because in the code there are: Vector3.zero, but we want, for example if we change the position on the unity scene, the object sync their position even the client connected.

    How we can fix that problem and make the reflection of the spawn unit?

    CODE:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;


    public class syncCubo : Photon.MonoBehaviour {
    Vector3 realPosition = Vector3.zero;

    void Update()
    {
    if (photonView.isMine)
    {

    }
    else
    {
    transform.position = Vector3.Lerp(transform.position, this.realPosition, 0.1f);
    }
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
    if (stream.isWriting)
    {
    stream.SendNext(transform.position);
    }
    else
    {
    this.realPosition = (Vector3)stream.ReceiveNext();
    }
    }
    }

    Or is just camera inverted? And the clash royal map is made in 3D.
  • Hi @Minds,

    Or is just camera inverted? And the clash royal map is made in 3D.


    At least I would assume that the camera is simply inverted. Furthermore I would assume that just the position of the objects get synchronized and the rotation is handled locally to display the game properly.