- Home /
 
photonnetwork.instatiate doesnt work?
Hey guys, i am creating an online tps game, but when i try instatiate the bullet it doesnt spawn? can someone help me? heres the code:
 using UnityEngine;
 using System.Collections;
 using Photon;
 
 public class Shoot : Photon.MonoBehaviour {
     public float WaitTime = 0.5f;
     public GameObject photon;
     // Use this for initialization
     void Start () {
     }
     
     // Update is called once per frame
     void Update () {
         WaitTime -= Time.deltaTime;
 
         if(WaitTime <= 0)
             WaitTime = 0;
         if(Input.GetMouseButton(0) && WaitTime == 0) {
             Debug.Log("TestShoot");
 
             WaitTime = 0.5f;
             GameObject bullet = PhotonNetwork.Instantiate("OnlineBullet", transform.position, transform.rotation, 2);
 
         }
             
         
     }
 }
 
              Do you have any error ?
Are you sure you enter the if (Input.Get$$anonymous$$ouse...) section ?
Does the console print "TestShoot" ?
Do you have a prefab named "OnlineBullet" ?
Are you sure the bullet is not instantiated at all, maybe it is not visible in 3D view, check in the inspector if it is really not there.
Answer by tobiass · Dec 17, 2014 at 09:41 AM
You should not Instantiate bullets in the first place. I doubt you simulate gravity or headwind on them, so they have a startpoint, speed and direction. If you send this for a shot, anyone can simulate the bullet on its own.
Doing that is cheaper than instantiate, update the position and destroy the network object.
Your answer