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:
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?