Photon Cloud and Player Instantiation

Hi Tobias,

EDIT: Writing this must have been therapeutic because I tried it and my idea worked, so far as just keeping control on the local player.

Now I have another problem, the movement isn't being smoothed at all, its choppy. I copied the OnSerializePhotonView from the AngryBots PUN demo. It was like this:

[code2=csharp]if (!photonView.isMine)
{
if (_correctPlayerPosition != Vector3.zero)
{
if (Vector3.Distance(_correctPlayerPosition, transform.position) < 4)
{
transform.position = Vector3.Lerp(transform.position, _correctPlayerPosition, Time.deltaTime * 5);
transform.rotation = Quaternion.Lerp(transform.rotation, _correctPlayerRotation, Time.deltaTime * 5);
}
else
{
transform.position = _correctPlayerPosition;
transform.rotation = _correctPlayerRotation;
}
}
}[/code2]

But even with the Lerping it isn't really smoothed at all.


OLD POST BELOW:

I'm trying to put together a simple project with Photon Cloud to test my character controller. However I ran into the same problem as you had in the Marco Polo tutorial where all player prefabs instantiated with PhotonNetwork.Instantiate are controlled by every player.

I've gotten as far as I can with the Marco Polo demo, but I've built a rather complicated state machine to control my player (its this one http://unitygems.com/fsm2/). It has a delegate system so that I have all the different monobehavior functions for every state (like Move_Update, Idle_Update, Attacking_Update, etc). It would ruin the whole thing if I had to keep an isControllable structure in every one of these, and constantly updating the state would also really mess with it. But I can't just disable it either because the animation layer requires the state.

I was thinking, maybe I could have my playerPrefab have a default "remote" blank state machine that can keep track of the states (and update it on OnPhotonSerializeView) and then remove that and add a custom LocalClientFSM when the client instantiates its local prefab.

Is it going to work fine to have each player have an added script only on their own client? Do I just have a GameManager make the PhotonNetwork.Instantiate call and then swap the scripts locally? That should mean its only modified locally and won't mess with anything right?

Comments

  • If it's not lerped, then the distance will be >= 4. This could happen, of course.
    Debug out which values are currently worked with and adjust your constants accordingly.
  • You are not only a smart mother f-er but you have the heart of gold to sit here and answer all our noobie questions.

    Thank you.
  • :lol:
    Thanks