I NEED HELP. Photon Collisions

Any one can help me to pass OnCollisionEnter as RPC .. or suggest a way so that i can detect collisions that are happening from the clients player to the server player. thanks

Comments

  • Ugh yeah sure....I don't think that you can send "OnCollision" via an RPC, but I am also pretty sure that you wont have to. What are you trying to do on collision? Reduce health or something like that?
  • edited April 2014
    yes thats what i am trying to do. for ia reason i dont know it is always entering R2() and never R1() even though i am changing the name of the player onjonedroom



    void OnCollisionEnter(Collision collision){


    if (collision.gameObject.name == "Rocko1" && sprint == true){


    photonView.RPC("R1",PhotonTargets.AllBuffered,null);

    abilityQProperties = true;

    photonView.RPC("trail1True",PhotonTargets.AllBuffered,null);
    photonView.RPC("trail2True",PhotonTargets.AllBuffered,null);

    photonView.RPC("crouch",PhotonTargets.AllBuffered,null);


    StartCoroutine(wait());
    sprint = false;
    }


    if (collision.gameObject.name == "Rocko(Clone)" && sprint == true)


    photonView.RPC("R2",PhotonTargets.AllBuffered,null);

    abilityQProperties = true;

    photonView.RPC("trail1True",PhotonTargets.AllBuffered,null);
    photonView.RPC("trail2True",PhotonTargets.AllBuffered,null);

    photonView.RPC("crouch",PhotonTargets.AllBuffered,null);

    StartCoroutine(wait());
    sprint = false;
    }


    [RPC]
    void R1()
    {
    Rocko1 = true;
    Debug.Log("yellow");
    }


    [RPC]
    void R2()
    {
    Rocko2 = true;
    Debug.Log("yellow1");
    }




    then in another class i am doing if rocko1 = decrease health of server player .. and if rocko2 = true .. decrease his health of client player ..
  • seems like the client player is collinging with rocko(clone) .. although i have changed the name of the server player to rocko1 .. ?!?!
  • Well the problem is the collision.gameObject.name part: It would be much easier to use a "tag" (so collision.gameObject.tag). This is because whenever an object is instantiated, it is automatically called itsname + (clone). So my advice: Try it by checking for the objects tag on collision. Tell me if that worked!
    Small note: I see you are adding "Null" at the end of every RPC call. You don't have to do that.
  • hmm could be and in fact i was using tags before .. the problem here is that when server and client choose the same player it will have the same tag ... i will try to change the tag from code and increment a number on each joined player .. i will get back to you.
  • Okay do that! I don't quite get what you mean with "server and client" but I hope you got the right idea and that things work out!
  • yes i managed to solve the problem mate .. it wasen't exactly as you described .. but you helped me out to figure the problem so thanks. it was the names.. when i changed the names i was not sending them as rpcs soo yeah thanks :)
  • Haha no problem, great that you found a solution. I was pretty sure that this was part of the problem :)
Sign In or Register to comment.