How to find ViewID as attacked by

Options
im just do attack to otherplayer in multiplayer using Photon Network,
illustration :
- myPlayer attack to Player1 (using PhotonPlayer.customProps as HP), --> method HP(-10)
if(other.collider.tag == "Player")
{
 other.GetComponent<PhotonView>().owner.HP(-10);
}
by this code, other = Player1
=================================>
its very easy by Photon.
and my question is simple : how to know the ViewID of attack me, if me as Player1?

Comments

  • iHaveReturnd
    Options
    If I'm understanding you correctly, it would be as simple as doing:
    if(other.collider.tag == "Player")
    {
         other.GetComponent<PhotonView>().owner.HP(-10);
         int otherID = other.GetPhotonView().viewID;
    
         //you can find the object later by doing this type of deal, 
       //  but this is an unnecessary step in your collider check
         Transform otherPlayer = PhotonView.Find(otherID).transform;
    }
    
    
    
    
  • If I'm understanding you correctly, it would be as simple as doing:
    if(other.collider.tag == "Player")
    {
         other.GetComponent<PhotonView>().owner.HP(-10);
         int otherID = other.GetPhotonView().viewID;
    
         //you can find the object later by doing this type of deal, 
       //  but this is an unnecessary step in your collider check
         Transform otherPlayer = PhotonView.Find(otherID).transform;
    }
    

    hohohoho..thanks iHaveReturnd, for GetPhotonView(), its new to me
    i will tryin about PhotonView.Find
    ..
    anyone else hav an idea?