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

[PUN Classic] instantiating objects and syncing position one time

$
0
0
Hi,

Recently trying out Photon and let me say it works fantastic however as learning goes there is always issues. I have read up a bit that you should try to avoid shoving a photonview on every object so I have tried to do so however I'm having quite a few issues getting each client to recognise the position of the object without using a photon transform view. I've tried numerous things and have not got very far but here's the code I've got at the moment. Hopefully i'm not totally of from the end result however any help would be much appreciated.
    void BuildSystem()
    {
        if (buildMode == true)
        {

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Input.GetMouseButtonDown(0))
            {
                if (Physics.Raycast(ray, out hit))
                {
                    photonView.RPC("BuildSystemNetworked", PhotonTargets.All);
                }
            }
        }
    }


    [PunRPC]
    void BuildSystemNetworked()
    {
        if (PhotonNetwork.isMasterClient)
        {
            Instantiate(blocks[0], hit.point, Quaternion.identity);
        }
    }
I mainly just one want transform.position and thats it. If i'm wrong and photonview is needed for every object i'll happily put it on however I like to make sure i'm doing the right things for the best performance.

Thanks,
Monsieur_Alpha

Viewing all articles
Browse latest Browse all 8947

Trending Articles



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