2D game, how to send info to show that sprites were flipped horizontally?

Options
I setup movement and animations but flipping sprites i dont know how to do.

For flipping locally i have:

//flip the sprites
if (Input.GetAxis ("Horizontal") > 0.1f)
transform.localScale = new Vector3 (-1, 1, 1);


if (Input.GetAxis ("Horizontal") < -0.1f)
transform.localScale = new Vector3 (1, 1, 1);



Here is my send and receiving of transform and animation triggers: (remember this is 2D so no rotation)


public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
if (stream.isWriting) {
// This is OUR player. We need to send our actual position to the network
stream.SendNext(transform.position);
stream.SendNext(anim.GetFloat("speed"));
stream.SendNext(anim.GetFloat("speedY"));
stream.SendNext(anim.GetBool("grounded"));
stream.SendNext(anim.GetBool("sitting"));




} else {
// This is someone else's player. We need to recieve their position
realPosition = (Vector3)stream.ReceiveNext();
anim.SetFloat("speed",(float)stream.ReceiveNext());
anim.SetFloat("speedY",(float)stream.ReceiveNext());
anim.SetBool("grounded",(bool)stream.ReceiveNext());
anim.SetBool("sitting",(bool)stream.ReceiveNext());

}

Comments

  • Tobias
    Options
    Wouldn't you flip sprites based on their speed?
    I assume that speed is positive or negative, depending on direction.
  • Pwego
    Options
    Tobias said:

    Wouldn't you flip sprites based on their speed?
    I assume that speed is positive or negative, depending on direction.

    My code I posted already includes flipping based on movement speed. I need to know how to code over photon to let other players to flip my sprite as well. If its as simple as sending a bool over I just need that code. This seems so simple, but I cant find anything online. I has bools and floats sent over but they're through the animator and removing the anim befor the SetBool throws an error.

  • Tobias
    Options
    As your code already includes flipping by movement speed, use it on the receiving side as well. It's the same for all characters (no matter if local or not).
    That is the best solution, because it's lean for the networking.

    If you want to send another value and don't know how, please do the Marco Polo Tutorial before you continue. It's important you can solve this on your own.
    http://doc.photonengine.com/en/pun/current/tutorials/tutorial-marco-polo