- Home /
How can I spawn a player prefab via script in a multiplayer game?
Hello, i want to create a multiplayer fps. But with different player prefabs. So i cant use the player spawning of the network manager. Can somebody help me?
Answer by Jeswer · Feb 05, 2016 at 04:38 PM
Hi,
You can store your player prefabs in the Resources folder in your assets. Then you can spawn the player through script by using:
GameObject prefab = (GameObject)Resources.Load("Name_Of_Your_Prefab");
GameObject player = Instantiate(prefab);
Transform t = player.transform;
//Set postion, rotation and parent of your player here:
Yes I tried this before. But then I wasnt able to see the other players in the network.
Answer by Taxen0 · Feb 03, 2016 at 09:15 PM
I would suggest looking at this live training tutorial from Unity for some basic tips when making a 3d shooter: http://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/fragmas-2-multiplayer-fps
if you want to be able to change the prefab that gets spawned you could for example have a menu when you connect to the server where you can choose your "class"/prefab, and then spawn the correct one based on that selection.
Your answer
![](https://koobas.hobune.stream/wayback/20220612062906im_/https://answers.unity.com/themes/thub/images/avi.jpg)