TAKE DAMAGE RPC CALLED MULTIPLE TIMES
Options
I am getting pretty annoyed right now.
I am spawning a bullet that detect whether it touches a player with OnTriggerEnter2D. When it does touch a player, it does two checks to see whether the player is the master client and if the player is mine.
Then, it does a "Take Damage" PC to that one player. On the TakeDamage function on the player, I AGAIN check to see if the player is the master client so it the Take Damage function will only call ONCE. Then I subtract health and update the ui.
But what happens when I run it? When shooting another player, the health function doesn't call ONE time, but around 3-8! What the heck is happening. I will smash my computer if this doesn't work.
Thanks.
Sully
I am spawning a bullet that detect whether it touches a player with OnTriggerEnter2D. When it does touch a player, it does two checks to see whether the player is the master client and if the player is mine.
Then, it does a "Take Damage" PC to that one player. On the TakeDamage function on the player, I AGAIN check to see if the player is the master client so it the Take Damage function will only call ONCE. Then I subtract health and update the ui.
But what happens when I run it? When shooting another player, the health function doesn't call ONE time, but around 3-8! What the heck is happening. I will smash my computer if this doesn't work.
Thanks.
Sully
0
Comments
-
Here is the script on the Player and on the Bullet.
https://drive.google.com/file/d/1Nux9h0vfe5f0tyJ47RHqGXbljdy3a6CT/view?usp=sharing
https://drive.google.com/file/d/1HLAJdHlFl5by_U4BpQqpJg9rcBlOK79F/view?usp=sharing0 -
Turns out I had multiple colliders on the player, so OnTriggerEnter2D was being called Twice. hehe sorry0