Not sure how hard this is: Unity Networking class system.
Ok so I'm pretty good at unity, I know my way around it and I'm good at c# (I can make 2D games with it without unity...) but have no idea where to start in unity Script... but anyway, I've been trying for like 4-5 months now to get this system to work, but every time I do, I give up because it's just confusing me. So what I want is a system which lets me have 6 different classes with different object's as their avatars and different spawns and so on...
So far I have added support for 2 different classes and 1 spawn. Anyway the issue that I have is:
I have different classes, however dependent on the class of the local player, depends on the class of the every other object... I'll show with some pictures in case that made no sense:
and here is the code:
Character button chooser:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SetCharacter : MonoBehaviour {
public string setCharacter;
public WhatCharacter whatChar;
public void Set(){
whatChar.character = setCharacter;
//GameObject.Find("StartMenu").SetActive(false);
Application.LoadLevel(1);
}
}
character maker(On the player object which is created by the the NetworkManager):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class MakeCharacter : MonoBehaviour
{
GameObject me;
GameObject Player;
public GameObject testClass;
public GameObject testClass2;
public Mesh testClassCollider;
public WhatCharacter whatChar;
void Start()
{
me = gameObject;
if(whatChar.character == "") {
Debug.Log("HAS WORKED!");
Player = GameObject.Instantiate(testClass) as GameObject;
Player.transform.parent = me.transform;
Player.transform.position = me.transform.position;
NetworkServer.Spawn(Player);
}
else if (whatChar.character == "Testing")
{
Debug.Log("HAS WORKED!");
Player = GameObject.Instantiate(testClass2) as GameObject;
Player.transform.parent = me.transform;
Player.transform.position = me.transform.position;
NetworkServer.Spawn(Player);
}
}
}
So there you go, thank you in advance :)
If you happen to know how to fix this in boo script and non of the other, I know how to program in python too... :)
Answer by arnold577 · Sep 03, 2017 at 08:09 PM
Ok, for anyone in the future facepalming like me at the fact they were going about this completely the wrong way... here is how to do it:
Your answer
Follow this Question
Related Questions
UNet Queries 1 Answer
Can Photon Unity Network be used for MMO prototype? 0 Answers
Best way to learn Networking in general 0 Answers