Home Game Development networking – drawback utilizing OnStartServer() for unity multiplayer networked sport

networking – drawback utilizing OnStartServer() for unity multiplayer networked sport

0
networking – drawback utilizing OnStartServer() for unity multiplayer networked sport

[ad_1]

UPDATE: i’m nonetheless scratching my head over this. The means i see it, the Awake() perform is barely invoked once I load it within the Editor, but when I put the prefab Loading line into OnStartServer() it simply doesnt load something, presumably as a result of it hasnt managed to load the prefab but … i feel it’s one thing to do with when it switches Scenes from the offline to on-line in NetworkSupervisor, i feel this script and others are being dropped as a result of the DontDestroyOnLoad command wasnt referred to as resulting from Awake not being referred to as.

Hello everybody I’m making a soccer sport which you management one participant from the staff. It will join 11v11 gamers per server (utilizing a “Host” appearing as server and consumer, and different shoppers connecting to them)

I consider I’ve adopted the examples and data offered by Unity to the letter, however I can not seem to get it working correctly.

The drawback: My code appears to work tremendous, offered I open the ‘Host’ occasion from the Unity Editor, but when I make the total construct model the Host it doesnt work.

Strangely all my player-objects will all spawn and act precisely as I meant, however the ball is not going to spawn until the ‘Host’ occasion is the one opened inside Unity Editor.
I’ve made the Ball a Network Identity, NetworkRework and so on and Registered Prefab within the NetworkSupervisor in inspector.

Here’s the code I’m utilizing to spawn the ball on the server, what could possibly be the issue as I actually don’t have any concepts, thanks:

utilizing UnityEngine;
utilizing UnityEngine.Networking;

public class MatchdayManager : NetworkBehaviour {
GameObject ballPrefab;    

non-public void Awake()
{
    DontDestroyOnLoad(this);

    ballPrefab = Resources.Load<GameObject>("Prefabs/Ball");
}

public override void OnStartServer()
{
    Debug.Log("on server begin referred to as");
    GameObject go = Instantiate(ballPrefab);
    NetworkServer.Spawn(go);
}


}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here