PhotonStream.SendNext C# (CSharp) Method

SendNext() public method

Add another piece of data to send it when isWriting is true.
public SendNext ( object obj ) : void
obj object
return void
    public void SendNext(object obj)
    {
        if (!this.write)
        {
            Debug.LogError("Error: you cannot write/send to this stream that you are reading!");
            return;
        }

        this.data.Add(obj);
    }

Usage Example

Esempio n. 1
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if(stream.isWriting){
            // this is our player, we send of posision data here
            stream.SendNext(transform.position); //send our posision to the network
            stream.SendNext(transform.rotation); // send our rotation to the network
            stream.SendNext(anim.GetFloat("Speed"));
            stream.SendNext(anim.GetBool("Jumping"));
            stream.SendNext(anim.GetFloat("AimAngle"));
        }
        else {
            //this is everyone elses players, we recieve their posisions here

            // right now realPosition holds the player position on the Last frame
            // instead of simply updating "RealPosition" and continuing to lerp
            // we MAY want to set out transform.position IMMEDIITLY to this old "realPosition"
            // then update realPosition

            realPosition = (Vector3)stream.ReceiveNext(); //recieve others posisions
            realRotation = (Quaternion)stream.ReceiveNext(); // recieve others rotations
            anim.SetFloat("Speed", (float)stream.ReceiveNext());
            anim.SetBool("Jumping", (bool)stream.ReceiveNext());
            realAimAngle = (float)stream.ReceiveNext();

            if (gotFirstUpdate == false) {
                transform.position = realPosition;
                transform.rotation = realRotation;
                anim.SetFloat("AimAngle", realAimAngle);
                gotFirstUpdate = true;
            }
        }
    }
All Usage Examples Of PhotonStream::SendNext