Why is my custom health and damage system not replicating properly?

Im building a complex health system for my game and event found many tutorials for what I’m trying to achieve so it’s hard to know if Im doing things right.

So far Im using components for both the health and dealing damage.

My current issue is when a client tries to deal damage to anyone it only wants to apply damage to a certain character (no matter what character is being hit) Heres my code.

On my character that can attack I have this code it uses the deal damage component:

Here is inside the deal damage component:


Should I be doing something different? Ive heard of using interfaces but I’m not sure it would be good for this. Why does the client work strange?

Turns out my line trace was casting from the wrong camera, ended up just hitting the same character. Instead I traded out camera manager for the exact location and rotation of the camera being used. I assume there are some issues getting camera manager form multiple clients.

Now the problem is i can’t getthe correct rotation of where the camera is looking

Im now placing the camera logic before the server event, however is that safe to do? will it be accurate?

this is fine, but you’d want to test it with network emulation on, it could feel quite laggy.

the alternative is to do the line trace on the client, send a target and the server can verify if that target is reasonable

For the servers trace you should use the following. It will match the client pretty accurately.

Do Not pass camera to the server. It opens the door for cheating. Server needs to get its own references and execute logic based on authoritative transforms.


To apply damage correctly you should use the engine functions. Apply Damage, Apply Point Damage etc.