- Home /
Hiding in Grass or object when player enters it in photon pun game?
Hey guys this is a broad question I guess but can anyone help me with this function. I haven't seen anything on it yet.
I have a photon pun classic game with players fighting each other and I wanted to add when players enter a grass patch or something like to hide the character from other players in the room but the player still see his character but become unbidden when he attacks or if another player enters into the grass then anyone in the grass can see each other. Like in league of legends. So I have a character entity script with photon view attached to it. So I guess it would be on enter hide the renderer something like that? If anyone could help with this thanks
Answer by Captain_Pineapple · Aug 22, 2019 at 11:35 AM
Basically yes. When you enter a grass patch (I'll leave the detection of this to you) you basically set some kind of flag on your character that symbolises that you are hidden. Your yourself always leave your renderer on but anyone who has the grass flag while you don't have it becomes invisible by deactivating his renderer.
This then only leaves the question of synchronization. This can be done in multiple different ways. If you want to be completly sure that this is synced and you know that this grass/nograss state does only change like once a second then use a rpc for this. Depending on your game setup you might also save bandwidth by just checking the entering of grass for every player at every game instance. the position information basically carries the information of the grass/nograss state hidden for you along.
If somehting was unclear or you have further questions on this let me know.
If you need more specific help on this please share some code snippets of where you are stuck.
Your answer
Follow this Question
Related Questions
How to list the rooms that are there [PUN] 2 Answers
Sync string array Photon 0 Answers
[Photon] How to sync own physic 0 Answers
Photon PUN 2 RTS one time information sharing 0 Answers
Pun2 and SteamVR 2.0 integration? 3 Answers