- Home /
Question by
jackson1412able · Oct 07, 2017 at 08:48 AM ·
networkingnetworkspawn
How to network spawn an object from a downloaded asset bundle
Hi guys, how do i networkserver.spawn an object from a downloaded asset bundle?
I don't want to use public GameObject whereby the prefab can be pre-imported..
Please help..
Here is my load asset script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class LoadAsset : NetworkBehaviour {
//I don't want to pre-import prefabs
//public GameObject cuboid;
public void Start(){
cuboid = GameObject.FindGameObjectWithTag ("DraggableItem").GetComponent<GameObject> ();
}
public override void OnStartServer(){
var cub = (GameObject)Instantiate (cuboid, transform.position, transform.rotation);
NetworkServer.Spawn (cub);
}
}
Comment
You download the asset bundle. You load the object from the asset bundle, providing that it's a prefab, you pass the variable of the loaded object into the cuboid variable and pass that to the instantiate method... There's nothing complicated here.
All the info about loading from bundles is here..
Your answer
Follow this Question
Related Questions
UNET Network.Spawn and child objects 1 Answer
network card game 2 Answers
zombie network spawn! help" 0 Answers
UNET save server (world) progress 1 Answer
UNET NetworkServer.Spawn intermittently not called on clients 1 Answer