Cast to different players in multiplayer

Say I have a Character class with an attribute called keyNumber, and a key item actor class, and I want my character to be able to pick up the key item when walking close up to it.

I tri to achieve this using the logic like this: the key item has a sphere collision, and when it’s overlapped by a character it would cast to the character and call a function to add 1 to the keyNumber. Also did a switch Has authority here:

The problem is, when i was debugging this process with a dedicated server and two players, I found that the “cast to BP_Human” node in the key item blueprint would cast to both players, not only the player who walked close up to the key. This resulted in the addKeyNumber function being called multiple times, as you can see below:

191156-capture.jpg

It feels like that the key item is casting to all the characters with the same class, but not the one specific character who actually walks up to it.

Should I tweak the blueprint with something like get player controller and judge it with the player index?

That’s definitely not what’s going on, that isn’t possible. Would need to see more of the code to understand what is going on. Also, the pattern in your second image is almost always an antipattern. If something needs to be done authoritatively, it should be done only on the server, and then the new resulting state replicated to the client(s).

thx for the quick reply. I gotta check the tutorial on networking one more time then see what actually happens here

…So it seems that I found the reason…It has nothing wrong to do with the character blueprint, it’s because there’s not a authority protection in the key item blueprint…