Scene enemies that fight for players?

Options
Hello,

My game is setup such that a network player can convince enemies to fight for them against other network players . Ie the enemies will attack other players.

The other constraint is that these enemies can switch which player they will fight for.

I currently have about 30 enemies spawned as network gameobjects.

I've looked around to see if there is a way to setup network "enemy properties" for the enemies that can switch sides. To keep track of which enemies are on which players side.

Is there an "enemy" custom property that can change the network state of the enemies so that all players are aware/notified of enemy alliances?

Or should I handle this in another way?

Answers

  • vadim
    Options
    Hi,

    Since your enemies are PhotonView objects, you can synchronize their properties across network by RPC or via OnPhotonSerializeView (same way as 'position' property is synchronized in PUN).

  • FGStud
    Options
    A network player can access properties set via PunRPC or OnPhotonSerializeView?

    Basically I need a way for a network player to access if an enemy is a team mate.

    Currently I populate an array of enemy GameObjects like this but this doesn't work over network:

    GameObject[] gos; gos = GameObject.FindGameObjectsWithTag("TeamBlue");

    How would I populate an array of "network enemies" with the custom propery team = blue for example?

  • vadim
    Options
    First there is no such thing in Photon like object custom properties (but player and room custom properties exist). I meant class property or field or even tag as in snippet above which you can synchronize via RPC or OnPhotonSerializeView by simply sending the value over network and setting local field to received value.
    To populate an array, when property changed, update local array for 'blue' with reference to updated object and remove this reference from all other arrays.
    Note that if you synchronize tags then no need to use arrays.