Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Third Party [PhotonCloud] Whats Wrong With my Instantiate Bullet Script?

Discussion in 'Multiplayer' started by jorn818, Oct 8, 2016.

  1. jorn818

    jorn818

    Joined:
    May 12, 2013
    Posts:
    100
    Whats Wrong with my script, im kinda new to Photoncloud and the lack of documentation is staggering (finding documentation anyway) but thats not my main problem, Im making a very basic shooter using prefabshooting (the game is played with 6 players max so its not that straining) problem is the script doesnt seem to be working, what i want is for other players to be able to see the rigidbody bullet.

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. public class ShootingPrefab : MonoBehaviour
    7. {
    8.     public Rigidbody theBullet;
    9.     public float Speed = 200f;
    10.     PhotonView view;
    11.     // Use this for initialization
    12.     void Start()
    13.     {
    14.         view = GetComponent<PhotonView>();
    15.     }
    16.  
    17.  
    18.  
    19.    
    20.     void Update()
    21.     {
    22.  
    23.         if (Input.GetMouseButtonDown(0))
    24.         {
    25.             var clone = PhotonNetwork.Instantiate("theBullet", transform.position, transform.rotation);
    26.             clone.velocity = transform.TransformDirection(Vector3(0, 0, Speed));
    27.  
    28.             Destroy(clone.gameObject, 3);
    29.         }
    30.     }
    31. }
    32.  
    33.  
    upload_2016-10-8_23-7-57.png
     

    Attached Files:

  2. Mrslayer01

    Mrslayer01

    Joined:
    Mar 23, 2014
    Posts:
    30
    try this to get rid of that error:

    Code (JavaScript):
    1. var clone = PhotonNetwork.Instantiate("theBullet", transform.position, transform.rotation, 0);
    Sorry wish i could be of more help, I too am struggling with Photon Documentation :/