Activate and deactivate object
Options
iikii
✭
Hi, i have a really hard time figuring how to do this simple action of showing the activation and deactivation a gameobject such as my character's weapon that is a child of my character.
I searched it and there's no reliable help. I am sure this should be simple since I can't find anything to guide me.
Please do share on how to solve this, thanks.
I searched it and there's no reliable help. I am sure this should be simple since I can't find anything to guide me.
Please do share on how to solve this, thanks.
0
Best Answer
-
Hello ,
If you want to activate/ deactivate gameobject on network I would suggest RPC calls such as this one below[PunRPC] private void RPC_HandleWeapon(int playerViewID, bool active) { GameObject player = PhotonView.Find(playerViewID).gameObject; // get child by position GameObject body = gameObject.transform.GetChild(0).gameobject; // get child by name GameObject wpn = player.transform.Find("Weapons").gameobject; weapon.SetActive(active); }
6
Answers
-
Hello ,
If you want to activate/ deactivate gameobject on network I would suggest RPC calls such as this one below[PunRPC] private void RPC_HandleWeapon(int playerViewID, bool active) { GameObject player = PhotonView.Find(playerViewID).gameObject; // get child by position GameObject body = gameObject.transform.GetChild(0).gameobject; // get child by name GameObject wpn = player.transform.Find("Weapons").gameobject; weapon.SetActive(active); }
6 -
Thanks, i think i managed to make it work. I am using playmaker though.
BUT can i understand how to use 'broadcast to player' in my situation? I experiment with it alot and it always fail even though i gotten the player name and player gameobject right.0 -
Sorry i dont use playmaker so dont know much about it0