Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.Networking;
- public class InstSynCube : NetworkBehaviour
- {
- public Camera Caaamera;
- public GameObject Cubee;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update ()
- {
- if (!isLocalPlayer)
- return;
- RaycastHit hit;
- Ray ray = Caaamera.ScreenPointToRay (Input.mousePosition);
- if (Physics.Raycast (ray, out hit, 100) && Input.GetMouseButtonDown (0))
- {
- Cmd_Inst (hit.point);
- }
- }
- [Command]
- public void Cmd_Inst(Vector3 pos)
- {
- GameObject go = (GameObject)Instantiate (Cubee, pos, Quaternion.identity);
- NetworkServer.Spawn (go);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement