Search Unity

Third Party damage system problem(photon) problem with sendMessage()

Discussion in 'Multiplayer' started by NikoBusiness, Oct 16, 2014.

  1. NikoBusiness

    NikoBusiness

    Joined:
    May 6, 2013
    Posts:
    289
    hey guys im stuck and cant find a solution... its nothing major its a little F***ing bug xD(that drives me crazy) so i couldnt handle it anymore and started this topic...
    so guys i have a static class named player where the health of a player is assigned and only the player with(photonview.ismine) can access it i will show the scripts and i am making dmg with sendmessage and it does not work :/ so here is the scripts...

    this is the function attached to the player
    Code (csharp):
    1.  
    2. void gotDmg(int dmg)
    3.     {
    4.         if (photonView.isMine)
    5.         {
    6.             Player.setHealth (dmg);
    7.             Debug.Log (Player.getHealth ());
    8.         }
    9.         Debug.Log ("Photonview isnt mine"); //this is showing up (its showing up by the sender not the other player who gets the damage i cant understand why
    10.     }
    11.  
    ITS SUPPOSED TO SHOW THE DEBUG.LOG BUT IT ISNT
    (that means that gotDmg isnt starting... )
    pls note this comment : //this is showing up (its showing up by the sender not the other player who gets the damage i cant understand why
    in the gotDmg function
    HERE IS THE SCRIPT ATTACHED TO THE WEAPON

    Code (csharp):
    1.  
    2. void OnTriggerEnter(Collider other)
    3.     {
    4.         if (other.gameObject.tag == "Player")
    5.         {
    6.  
    7.             int nameHash = me.GetComponent<CharacterMovement>().layer2CurrentState.nameHash;
    8.             int attackstate = CharacterMovement.attackState;
    9.  
    10.  
    11.             //Deal DMG if Attacking
    12.             if(nameHash == attackstate)
    13.             {
    14.                 int dmg = Random.Range(2,10);
    15.                 other.gameObject.SendMessage( "gotDmg", dmg );
    16.  
    17.  
    18.             }
    19.         }
    20.     }
    21.  
     
    Last edited: Oct 16, 2014
  2. NikoBusiness

    NikoBusiness

    Joined:
    May 6, 2013
    Posts:
    289
    guys the problem is with the tags i have to detect the other player with something other than tags or change the system

    how is it possible for collision detection with tags without confusing with the tags in the network?i mean if u are in the game with 2 clients and photonvie.ismine object has tag player and the other one with tag enemy? how is the enemyone in the scene of the where he is enemy (photonview not mine) is going to detect collision of the other? its going to detect the collision if its a sword kind of thing...
     
    Last edited: Oct 16, 2014