- Home /
PhotonNetwork.Instantiate() doesn't instantiate the prefab. Only Instantiate() works. Why?
I want a prefab with Line Renderer and PhotonView component to be instantiated on the network when "Fire1" is pressed. To do this I use PhotonNetwork.Instantiate() but it doesn't work. There is no error, the object just doesn't appear. When I use Instantiate() everything works as it should, but I need to send this information over the network.
// This doesn't instantiate the object
GameObject effect = (GameObject) PhotonNetwork.Instantiate ("bullet", startPos1, Quaternion.identity, 1);
When I use PhotonNetwork.Instantiate() to instantiate the object I and I try to access it using the code below I get the null reference exception error
// This gives me null reference exception
LineRenderer lr = effect.GetComponent<LineRenderer>();
lr.SetPosition (0, gun1.transform.position);
lr.SetPosition (1, gun1.transform.position + (gun1.transform.forward * 1000f));
Your answer
Follow this Question
Related Questions
Glitching Line Renderers upon tying to new game object 1 Answer
Line Renderers tied to ball keep teleporting/glitching after instantiate 1 Answer
Accessing a Function from an Instantiated Object 1 Answer
Object Pooling issue. GameObject instantiating 1 bullet instead of multiple bullets 1 Answer
Button not instantiating, no errors 2 Answers