The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

"photonView.IsMine" is set to false when it should be on true?? Please help

Jino_015
2022-07-17 19:27:13

Hi I'm making an multiplayer fps game using Unity.

In my game every player has a rocket launcher, and players can bounce around the map with their own explosions by shooting rockets directly under them. But when I tried to implement damage, I had an issue. Because players need to be able to shoot themselves without getting damaged, I had to disable damage to themselves somehow.

The issue I'm having now is that "photonView.IsMine" in the "Take damage" method always returns as false. even tho there is no reason for it too. Anyone know why this could be happening?

This is the "ExplosionDamage" script that gets instantiated as soon as the rocket collides(TakeDamage is called here!):

Anyone that could help me? I have been looking for a solution for the past 2 days.

Comments

Tobias
2022-07-18 10:33:25

Maybe you check the PhotonView on bullet?

Actually, bullets should likely not have a PhotonView and don't need to be network instantiated by PUN. At least, if you do a raycast to hit something.

This isn't related to your current woes but I'd recommend Fusion for a shooter. It is way more efficient and is built with shooters in mind.

Jino_015
2022-07-18 11:23:34

Tobias 2022-07-18T10:33:25+00:00

Maybe you check the PhotonView on bullet?

Actually, bullets should likely not have a PhotonView and don't need to be network instantiated by PUN. At least, if you do a raycast to hit something.

This isn't related to your current woes but I'd recommend Fusion for a shooter. It is way more efficient and is built with shooters in mind.

I am not using raycast to hit something, I instantiate the rockets.

"Maybe you check the PhotonView on bullet?"

What do you mean exactly? How would I do this?

Jino_015
2022-07-18 19:49:01

Update: I found the cause of the problem. It’s this line:

For some reason the RpcTarget causes players to be able to kill themselves.

Anyone know how I could stop this?

I’m also getting these errors only when a player kills itself:

Jino_015
2022-07-18 20:23:58

Another update:

The photonView.RPC line somehow gets executed even tho "TakeDamage" didn't get called?

The debug doesn't show? This must be a bug then right?

The Debug does show when shooting on other players as it should.

This is really really weird. How does the line still get called?

Jino_015
2022-07-18 22:30:35

This is everything that gets logged when a player kills itself:

And this is everything that gets logged when killing another player:

Here are all the debugs that are shown:

As you can see the debugs "TakeDamage" don't get logger but somehow the "photonView.RPC" line in "Take damage" still gets executed. Please help.

Tobias
2022-07-19 10:46:24

Don't set the console to "collapse" logs. This way, you will miss some entries, as they are grouped (no longer shown in sequence).

Unity will call OnTriggerEnter on all clients which show the networked scene. You need to make sure only one of those clients will actually test for a hit. If you don't get that done correctly, someone might test for a hit and decide "as the character is not mine, this is a hit", then call the RPC or TakeDamage. So a remote player suddenly decided if you hit yourself or not.

Back to top