How to update variables on an object via their photonView ID

Options
I was to create an PunRPC that broadcasts a photonview id and some variable updates.

I can't work out how to convert a photonview reference into something where I can see the attached game objects variables to edit.

The game object has public variables I want to update (floats and bools)

My last attempt was:

[PunRPC] public void AIAttack(int enemy) { PhotonView target = PhotonView.Find(enemy); // This is not seen as a valid variable to update target.gameObject.dead = true;

Best Answer

Answers

  • roskelld
    roskelld
    edited December 2016
    Options
    
    [PunRPC]
    public void AIAttack(int enemy)
    {
    PhotonView target = PhotonView.Find(enemy);
    
    // This finds the network id gameobject and script containing variable to change
    target.gameObject.GetComponent<EnemyLogic>().dead = true;
    }
    
    Thanks!

    Here's a sample of the working code