Question by
zembron · Jan 16, 2018 at 01:42 PM ·
spritesynchronizationflip
Flip sprite sync Network problem
Hello ! I'm creating a little 2D Multiplayer game. Players can see their sprites flipping but see the others players moonwalking. How can i do ? Thanks and sorry for my poor english ;) !
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class Flip : NetworkBehaviour {
private SpriteRenderer mySpriteRenderer;
// Use this for initialization
void Start () {
mySpriteRenderer = GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void Update () {
if (!isLocalPlayer) {
return;
}
// if the variable isn't empty (we have a reference to our SpriteRenderer)
if(mySpriteRenderer != null)
{
// if the A key was pressed this frame
if(Input.GetKeyDown(KeyCode.Q))
{
// flip the sprite
mySpriteRenderer.flipX = true;
}
if(Input.GetKeyDown(KeyCode.D))
{
// flip the sprite
mySpriteRenderer.flipX = false;
}
}
}
}
Comment