#NETCODE MULTİPLAYER
1 messages · Page 1 of 1 (latest)
You cant change network variables on the client
Network variables can only be modified by the server
You need to send a ServerRpc from the client that modifies the health value
[ServerRpc]
private void DecreaseHealthServerRpc(int amt)
{
playerHealth.Value -= amt;
}
Then when your code hits the other object, just call this member function on the health system you wish to apply damage to
By the way, remember that classes should only have one distinct ability. a health system should only care about health, and not shooting/input. This logic should be moved into a player class, or somewhere if you want to follow the best practices, and ensure things scale the best they can 😄
It will still work regardless
No worries
@alpine river I did what you said. but I get the following error on the host.
@alpine riverI fixed it. I'm sorry to bother you.