using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.Networking;
using System;
public class MapGen : NetworkBehaviour {
[Server] void DisplayMap() //creates prefabs
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
count += 1;
if(map [x,y] == 0){
float holdX;
float holdY;
if (y % 2 == 0)
{
holdX = x + 0.5f;
}
else
{
holdX = x;
}
holdY = y - ((float)y) / 8;
GameObject cloneGameObject = (GameObject)Instantiate(hex, new Vector3(holdX, 0, holdY), Quaternion.Euler(270f, 90f, 0f));
cloneGameObject.AddComponent<Tile>();
cloneGameObject.GetComponent<Tile>().visible = false;
cloneGameObject.GetComponent<Tile>().SetHole(); //NOT CALLING ON SERVER
cloneGameObject.GetComponent<Tile>().SetIdentifier(count);
tileDict.Add(count, cloneGameObject.GetComponent<Tile>());
NetworkServer.Spawn(cloneGameObject);
}
}
}
}
}
using System.Collections;
using System;
using System.Linq;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Networking;
//Basic skeleton of Tile class which will be used as grid node
public class Tile : NetworkBehaviour
{
[SyncVar]public bool visible = true;
Renderer rend;
[Server]public void SetHole(){
Debug.Log ("SETHOLE CALLED");
if (!isServer) {
return;
}
Debug.Log ("THE SERVER IS CALLING SETHOLE");
rend = GetComponent<Renderer> ();
if (!visible) {
rend.enabled = visible;
}
isHole = true;
blocked = true;
}
}
I’m not able to get the server to call SetHole(), what am I doing wrong?