Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Is there a way to synchronize alterations to a tilemap changed at runtime with SetTile()?

$
0
0
I've been having this issue for a while now and was wondering how to fix it. Basically I have a tree tile and when I left click while my mouse hovers over the tree, it's tile is set to null and an item is spawned. Now, the item spawning works fine but the tree tile being st to null doesn't synchronize over to other clients. Any fixes?
     void BreakDecor()
    {
        GameObject spawnedItem = PhotonNetwork.Instantiate("Item", new Vector3(selectedTile.x + 0.5f, selectedTile.y + 0.5f), Quaternion.identity);
        spawnedItem.GetComponent<ItemObjectHolder>().item = ItemDirectory.instance.itemDirectory[decor.GetTile<TileBase>(selectedTile).name];
        decor.SetTile(selectedTile, null);
    }
    void Update()
    {
        Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (Input.GetMouseButtonDown(0))
        {
            if (point.x - player.transform.position.x < distanceFromPlayer && player.transform.position.x - point.x < distanceFromPlayer && point.y - player.transform.position.y < distanceFromPlayer && player.transform.position.y - point.y < distanceFromPlayer)
            {
                selectedTile = decor.WorldToCell(point);
                if (decor.GetTile(selectedTile) != null)
                {
                    BreakDecor();
                }
            }
        }

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>