now i added a variable “gold” to the base character (int). Now i want, that when two players get very close to each other, both values of “Gold” will be added and devided by 2. Then set the “Gold” for eacht with this calculated value
Lets say
Player 1 has Gold: 100
Player 2 has Gold: 200
when they are very close to each other
p1 has (100+200)/2 = 150
p2 has (100+200)/2 = 150
my problem is, that i am not able to read the value from the other character to figure out, how much the other player has.
OnOverlapEvent cast from the actor output node of the event node, to the character blueprint (i guess both use the same?), then branch and make an equal bool check if the overlapped actor is indeed the player character blueprint. If true add the calculations for the replicated variables.
This is what i have so far. But it somehow does not work
It executes the “on overlap” to many times
i think, i did not correctly referenced to the “other” actor correctly. The “Gold” variable has both times the same value
do you have an idea what i did wrong?
i tried to set a bool to check, if overlap has benn executet within the last 5 seconds, but for some reason, this does not work. i guess, it is executet twice anyway for both players at the same time.
thanks very much in advance for helping
K
If it executes too often, try adding a DoOnce node after successful overlapped actor. If you want to use this overlap event again, you need to add a custom event and plug it into the DoOnce node reset input, after some time past, or try a reset input from OnComponentEndOverlap.
Thanks for your reply, i will try this. Do i correctly reference to the Variables and add them? im am not sure, if i do that correctly
thanks very much
p.s. it works only when i play as the server. when a player overlaps, it does not read the variable from other client or the server