Setting a local ulong vs IsOwner

In the DealDamageOnContact script in OnEnterTrigger2D we seem to be doing a bit extra to be able to set the ownerClientID via a ulong, additional method, and two trygets (one here, one in the projectile launcher) - what would happen if you simple inherited from NetworkBehaviour and used the IsOwner check that is built in/we use in other places? Are there unintended consequences that happen if we do it like that? Or is this just to show how you could get the network ID without inheriting?

Edit: I probably should have read the other question on this video (Network Object required4bawdu_gaMTE3Mjk2ODcyNy4xNjg3Mjk1ODUw_ga_2C81L26GR9*MTY4ODY0OTk5OC4yMS4xLjE2ODg2NTAwNDguMC4wLjA.) - however my question remains - what are the consequences of making the server projectile a networked object/doing it like this? Is it just unnecessary because that object should only be on the server/host? Being able to simply is “IsOwner” is/would be a lot more convenient…

To me, all of this seems a little redundant. We’ve already set the projectile to not collide with the player when we spawned it, so this whole section of ‘checking if we collided with the owner’ is pointless 'cos I don’t believe it ever will.

That being said, I don’t think checking IsOwner will work (I don’t know, I’m guessing) because I don’t think the player is the owner of the server-side projectile - the server is. Have you tested this?

1 Like

IsOwner certainly won’t work as is since the script isn’t a NetworkBehaviour but looking at the code again I realize I was tired and this is only set for the server projectile. I am not new to programming or network programming really, most of my questions come from being unsure about NGO specifically. I remember doing something very similar in Photon Fusion though (setting and checking against the owner ID) like this. I looked into this a little and from what I can tell we do this because (apparently) Physics2D.IgnoreCollision will stop a physics interaction between the player and the bullet but it is possible that die to latency it is possible the player to still damage themselves on the server without this check. I have not tested it much though that’s just what I found via some searching.

There have been a few approaches in this course to problems I have raised an eyebrow at, so I am just trying to separate what was a choice made for a reason and what was “just because” - for instance when OnCoinCollected is fired, you can just show it as part of the reset vs how it is shown because it seems to treat the host as a client in addition to the server.

1 Like

Privacy & Terms