Advertisement
AndrewRosyaev

InstSynCube

Apr 28th, 2016
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.Networking;
  4.  
  5. public class InstSynCube : NetworkBehaviour
  6. {
  7.     public Camera Caaamera;
  8.     public GameObject Cubee;
  9.  
  10.     // Use this for initialization
  11.     void Start () {
  12.    
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update ()
  17.     {
  18.         if (!isLocalPlayer)
  19.             return;
  20.         RaycastHit hit;
  21.         Ray ray = Caaamera.ScreenPointToRay (Input.mousePosition);
  22.         if (Physics.Raycast (ray, out hit, 100) && Input.GetMouseButtonDown (0))
  23.         {
  24.             Cmd_Inst (hit.point);
  25.         }
  26.  
  27.     }
  28.  
  29.     [Command]
  30.     public void Cmd_Inst(Vector3 pos)
  31.     {
  32.         GameObject go = (GameObject)Instantiate (Cubee, pos, Quaternion.identity);
  33.         NetworkServer.Spawn (go);
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement