Bullets wont collide for the other clients (SOLVED)

Well, I have made a flamethrower which is observed by a photonview. The character which holds the rifle (Which instantiated the rifle) sends if it shoots the rifle and recieves other players info of shooting hte rifle or not. Now, for some reason the bullet which is being instantiated from the observed rifle (In this case the flames from the flamethrower) Will show collision for the player which shot them and wont provide collision for the other player who sees the flame.. It just passes through the player who is being shot at for him and for the player who shoots it collides. The bullets are not being observed by any network view (Any photon viewer or whatever) and are instantiated by the regular instantiate and not by a PhotonNetwork.Instantiate();

Why is this happening if both clients are getting clientside instantiated bullets and theres collision only for the one who shot them?!?

Heres the BULLET SCRIPT:
using UnityEngine;
using System.Collections;

public class bullet_script : MonoBehaviour {

public GameObject playerOwn;
public float speed=50;
public GameObject me;
public float timed=5;
public int dmgvalue=5;

void Update()
{
transform.position+=transform.TransformDirection(0,1,0)*Time.deltaTime*speed;

if(timed>0)
{
timed-=1*Time.deltaTime;
}
else
{
Destroy (me);
}

}

void OnTriggerStay(Collider victim)
{
print ("crap?");
//if(victim.gameObject!=playerOwn)
//{
GameObject grave;
if(victim.gameObject.tag=="Player")
{
print ("isplayer!");
grave=(GameObject)Resources.Load("Collidedblood");
victim.gameObject.GetComponent<player_combat>().Wound(dmgvalue);

}
else if(victim.gameObject.tag=="Wood")
{
grave=(GameObject)Resources.Load("Collidedwood");
}
else
grave=(GameObject)Resources.Load("Collidedust");


Instantiate (grave,transform.position,transform.rotation);

Destroy (me);
//}

}






}


-- PROBLEM SOLVED - Had to put a rigidbody on the bullet. :) --

Comments

  • The issue doesn't seem to be in this code.
    Questions you should ask yourself (and find a answer for): What is the difference between the remote clients and the local one? Do you use isMine to disable some scripts or ridigbody? Or do you skip creating one, if you do that on the fly?
    You could pause the editor and check the values in the bullets. Remember those (especially "enabled" checkbox) and compare with those for remote players.
  • I have checked many times while pausing and found no wrong yet.
    The player is the only one which manages the whole issue, it checkes if the client has fired and sends other clients which use this value to send the local players combat component to instantiate (clientsidely the bullet).
    Heres the "nw_player" code which I have made for these issues:

    using UnityEngine;
    using System.Collections;

    public class nw_player : MonoBehaviour {

    public PhotonView playerPV;
    public Vector3 correctPlayerPos;
    public int animationInteger=0;
    public int animationRecieved=0;
    public int healthRecieved=100;
    public bool faceforRecieved=false;
    public bool ragdollRecieved;
    public bool ragdebugRecieved;
    public bool firedRecieved;
    public Vector3 directionRecieved;
    public string userRecieved;

    void Update()
    {
    if (!playerPV.isMine)
    {
    GetComponent<clientid2>().username=userRecieved;
    transform.position = Vector3.Lerp(transform.position, this.correctPlayerPos, Time.deltaTime * 20);
    GetComponent<player_movesys>().DisplayAnimation(animationRecieved);
    GetComponent<player_movesys>().facefor=faceforRecieved;
    GetComponent<player_movesys>().mousepos=directionRecieved;
    GetComponent<player_combat>().health=healthRecieved;
    GetComponent<player_ragdoll>().ragdoll=ragdollRecieved;
    GetComponent<player_ragdoll>().debugbool=ragdebugRecieved;
    GetComponent<clientid2>().username=userRecieved;
    GetComponent<player_combat>().firetrigger=firedRecieved;

    if(faceforRecieved)
    {
    transform.rotation=Quaternion.Euler(0,-180,0);
    GetComponent<player_movesys>().chest.LookAt(directionRecieved,Vector3.left);
    }
    else
    {
    transform.rotation=Quaternion.Euler(0,0,0);
    GetComponent<player_movesys>().chest.LookAt(directionRecieved,Vector3.right);
    }
    }




    }


    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
    if (stream.isWriting)
    {
    // We own this player: send the others our data
    stream.SendNext(transform.position);
    stream.SendNext(animationInteger);
    stream.SendNext (GetComponent<player_combat>().health);
    stream.SendNext (GetComponent<player_movesys>().facefor);
    stream.SendNext (GetComponent<player_ragdoll>().ragdoll);
    stream.SendNext (GetComponent<player_ragdoll>().debugbool);
    stream.SendNext (GetComponent<player_movesys>().mousepos);
    stream.SendNext (GetComponent<clientid2>().username);
    //COMBAT
    stream.SendNext (GetComponent<player_combat>().fired);
    }
    else
    {
    // Network player, receive data
    this.correctPlayerPos = (Vector3)stream.ReceiveNext();
    this.animationRecieved=(int) stream.ReceiveNext();
    this.healthRecieved=(int) stream.ReceiveNext();
    this.faceforRecieved=(bool) stream.ReceiveNext();
    this.ragdollRecieved=(bool) stream.ReceiveNext();
    this.ragdebugRecieved=(bool) stream.ReceiveNext();
    this.directionRecieved=(Vector3) stream.ReceiveNext();
    this.userRecieved=(string) stream.ReceiveNext();
    //COMBAT
    this.firedRecieved=(bool) stream.ReceiveNext();

    }
    }
    }


    MANY THANKS FOR ANYONE WHO WILL HELP ME SOLVING THIS FRUSTRATING PROBLEM!
  • PROBLEM SOLVED - Had to put a rigidbody on the bullet. :)