making Projectiles Visible

Rigs
Rigs
edited July 2015 in Photon Server
hi,
it's my first time here, sorry.

i have been searching for about 3 days now, for a way to make all players(player controlled objects) to be able to view the other players projectiles.

i have two players, i can shoot just fine with them but the other player can not see the others projectile. i have tried so many different ways. PhotonViews don't seem to work. using network.instantiate doesn't seem to work either, all with the OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) attached as well and having them viewed with the photon view.

i apologise if this has been discussed and answered, i just can't find anything that helps me.

Comments

  • here is an example code, it should work!
    at the top put this

    public GameObject Bullet;

    inside update put

    if(input.getKeyDown(KeyCode.Space)){
    photonView.RPC("NameOfFunction",PhotonTargets.All,null);
    }


    [RPC] OR if using newer Photon it would be [PunRPC]
    void NameOfFunction(){
    Whatever you want to happen in here. E.G. Instantiate
    instantiate(Bullet,transform.position,transform.rotation);
    }

    That's it lol.
    Bullet = the prefab you want to create, transform.position and transform rotation creates it from the object that's shooting it.
    If you want it to come from a specific spot, then make another gameobject at the top called public GameObject SpawnPosition;

    Then instead of doing instantiate(Bullet,transform.position,transform.rotation);

    you would do

    instantiate(Bullet,SpawnPosition.position,SpawnPosition.rotation);


    There you go, just make sure there is a photonView only on the object that is (SHOOTING IT). Don't need them on the bullet.

    Hope that helps buddy!