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

newbie server / client best practice question

$
0
0
Hello All,

I am relatively new to both Unity and photon. I have completed a few of the unity tutorials and wanted to try making a simple multiplayer game. I figured I would do a multiplayer version of roll a ball where a few players connect, collect all the objects, then you win.

I started playing around with the DemoRPGMovement scene.

I created a cylinder, made it a prefab then added the "PhotonView" and "PhotonTransformView" scripts that are attached to the "Robot Kyle RPG" prefab that comes with the demo. I then added the following lines to 'DemoRPGMovement' script in the 'server' build

void CreatePickupObjects()
{
Vector3 cubePosition = new Vector3 (50, 5, 62);
GameObject newSphere = PhotonNetwork.Instantiate ("Prefab1", cubePosition, Quaternion.identity, 0);
}

for the 'client' build, I removed these lines but kept the prefab.

My question is, is it mandatory for the Cylinder prefab to be in the client build so that the connecting clients can see the prefab? ( I tried making a client build without the prefab however the that client was not able to see the cylinder I am assuming the prefab needs to be loaded somehow from the server if it is not in the client build) Or would this be bad practice similar to calculating player move speed in the client which would lead to exploitation? Obviously this does not matter when I am just learning / playing around with the demo, but I was just curious from a best practice perspective if we should keep models in client builds, or if I should keep the client to a bare minimum and research loading the prefab from the server once the client is connected (If this is the case, would anyone be able to point me to a few tutorials or keywords that I can google to find a good example?)

If my post is confusing, I uploaded a quick video to youtube.

I ran my server out of unity, and I had 2 exe's one with the prefab in the client, and one without.

image

Viewing all articles
Browse latest Browse all 8947

Trending Articles