Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Instantiate New Gameobject with properties

$
0
0
Hi,
im developing a 1 vs. 1 multiplayer game, clash royale style.

I need to instantiate gameobjects (ex. monster). Each object has its own properties (ex. Health, Attack, Defense)

I managed to create the object with:
if (pv.isMine)
{
GameObject go1 = PhotonNetwork.Instantiate(this.player1Prefab.name, hit.point, Quaternion.identity, 0);
go1.GetComponent().initializePlayer(Role, Value, Health, Defense, Attack, Speed);
MonoBehaviour playerController = go1.GetComponent("PlayerController") as MonoBehaviour;
playerController.enabled = true;
}
else
{
GameObject go2 = PhotonNetwork.Instantiate(this.player2Prefab.name, hit.point, Quaternion.Euler(0, 180, 0), 0);
go2.GetComponent().initializePlayer(Role, Value, Health, Defense, Attack, Speed);
MonoBehaviour playerController = go2.GetComponent("PlayerController") as MonoBehaviour;
playerController.enabled = true;
}

At run, i can view only the script of the local player, so i don't know how can i retrieve the properties of remote object ? (ex. monster) to compare in case of collision (local vs remote monster).

you have any suggestions or some examples that you would recommend?
thanks

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>