- Home /
Problem is not reproducible or outdated
[PHOTON PUN] Players cant shoot each other?
Hey guys! So, I've been working with PUN for a while now, but whatever I do, I can't seem to get shooting to work. The problem is (by the title) that players can't shoot each other, and I have no idea why! But all I DO know is this: When a player shoots, they do detect shooting other players. When the player shoots another player, it get's a script on the other player and calls a function that deals damage to that player. Well, I use getComponent to get that script, but when I shoot, the GetComponent doesn't go through! In other words, for some reason I can't access the script! Here's my code to do the damage on the local player: https://paste.myst.rs/70m And my code to take damage on the other players: https://paste.myst.rs/vvw Any help would MUCH appreciated. Thanks!
Answer by Captain_Pineapple · Aug 10, 2019 at 10:26 AM
Hey there,
Please add debug.Logs in your shooting logic to see which object you actually hit. I guess you just have to replace all objectHit
by objectHit.transform.root
to make sure that whereever you hit the other player you will always access the same transform on them.
If this does not help please report back and post some more info about what you hit, how your hierarchy setup is with colliders and please make really really sure the raycast does not get stuck in your own player...
I did debug it and the players are hitting each other, but the method calling doesn’t always go through
Did you add else statements to all your ifs with a debug.log inside? then you can see which of the statements actually blocks you?
Hey man, I’m sorry, but I don’t think you understand. It’s the RPC that’s not going through, and that’s what I want to solve
well yes indeed, you should have mentioned a problem with rpcs...
that little tag at the start of your code snippet is easily missed.
So does the rpc not trigger for other players or does this whole function just not work as intended at other players instances?
The rpc doesn’t trigger on the other player yeah @Captain_Pineapple
If it's never even called at all then you should include the code where the rpc is sent.
No! Dude! The RPC is being called, but just not on the other players! I said that in my previous comment. And besides, the code where I call it is just a simple photonView.RPC(“Shoot”, RpcTarget.AllBuffered);
Do you have discord or something? Wanna chat there?
Follow this Question
Related Questions
Photon pun problem on send and read request 0 Answers
OnConnectedToMaster() vs IsConnectedAndReady? 1 Answer
Photon Networking Instantiating Problem 0 Answers
Callback for DNS entry error using Photon Networking 0 Answers
Unity networking tutorial? 6 Answers