1
\$\begingroup\$

I am developing multiplayer game in unity. For multiplayer i am using photon networking library. I created room and join client successfully.

But Problem is I am doing gameobject movent by this code:

public GameObject player;
IEnumerator Moving (String temp)
{

    for (int i = 0; i < 3; i++) {

        player.transform.DOMove (CurrentPositionHolder, 0.5f).SetEase 
           (Ease.Linear);   
        yield return new WaitForSeconds (0.5f);
    }
}

DoMoveis library here.

Problem is player movement is not synchronized.

For Synchronization I add photonview component to player gameobject.

And i call coroutine though RPC like this.

player.GetComponent<PhotonView>().RPC ("Moving", PhotonTargets.All, "temp");

Accordingly i changed coroutine like this:

[PunRPC]
IEnumerator Moving (String temp)
{

    for (int i = 0; i < 3; i++) {

        player.transform.DOMove (CurrentPositionHolder, 0.5f).SetEase 
           (Ease.Linear);   
        yield return new WaitForSeconds (0.5f);
    }
}

I got this error

Illegal view ID:0 method: Moving GO:player UnityEngine.Debug:LogError(Object)

\$\endgroup\$
5
  • \$\begingroup\$ Are you instantiating the object using PhotonNetwork.Instantiate? \$\endgroup\$
    – House
    Commented Dec 13, 2017 at 18:21
  • \$\begingroup\$ No, I instantiate it normally, Is it required to instantiate like that? \$\endgroup\$ Commented Dec 13, 2017 at 18:26
  • \$\begingroup\$ As far as I know, it is. Check out the tutorial documentation. \$\endgroup\$
    – House
    Commented Dec 13, 2017 at 18:43
  • \$\begingroup\$ I instantiate using PhotonNetwork.Instantiate, Error message not showing but if gameobject on client side move, it not showing at server side and vice-versa. I want sync it. \$\endgroup\$ Commented Dec 13, 2017 at 19:41
  • 1
    \$\begingroup\$ We'd need more details if you want that solved. Try making one of the tutorials work for you first, then apply what you learn to your project. \$\endgroup\$
    – House
    Commented Dec 13, 2017 at 19:57

1 Answer 1

0
\$\begingroup\$

Problem gets solved. I call Moving enumerator from method not directly using RPC. And Make method call using RPC.

And Most important thing is use transfrom instead of gameobject like this:

transform.DOMove (CurrentPositionHolder, 0.5f).SetEase(Ease.Linear);   
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .