Damage Processor altering the damage amount W/ Pun Integration

conraddu

Member
Hello,

I recently bought the the Third Person Controller, Agility Pack, and PUN multiplayer integration. I have been having an absolute blast playing with them and developing a fun project.

I have a question about the Damage Processor. I recently used the Damage Processor to create a subclass called DamageProcessorFloatingText, which generates floating combat numbers through Text mesh pro prefabs. (Later I learned that there is a floating combat numbers solution in UCC already)
I then went on to create a second subclass that extended the DamageProcessorFloatingText, called CritDamageProcessor. My hope for this class was to "roll some dice" for a critical hit, modify the damageData.Amount if a critical hit occurred, and then pass on the results to the base process function w/ the critical hit result baked into the damageData.UserData. This works great in a single player setting, I can see the critical hits appearing differently than the normal hits through my DamageProcessorFloatingText implementation. However, in a multiplayer setting there is something missing. W/ multiple clients running, the critical hits are not synchronized. I am assuming this is because modifying the damageData.Amount within the process function for one client doesn't actually do anything for the other clients on the network.

What would you recommend as the best solution for this problem? I just want to have a good way of modifying the damage (eventually with attributes) so that the clients are all aware that a critical hit has occurred.
 
Without actually looking into this (I just come across the post and had a thought) my thought, or question more so, is have you tried making CritDamageProcessor not a subclass so it works on its own? maybe the pun event that is fired doesn't support subclass of scriptable??
 
So the process function of Damage Processor ultimately calls IDamageTarget.Damage(), so the fact that CritDamageProcessor is a subclass of DamageProcessor shouldn't be a problem, since the workflow ties back into the standard damage workflow. The whole issue seems to be a problem with the way that the PUN integration allows each client to calculate their own damage, instead of only the master client calculating damage and then informing the clients of the damage dealt. But I am not really certain where to begin making this altercation so that DamageProcessor's can modify damage amounts in a networked setting.
 
I have been having an absolute blast playing with them and developing a fun project.
:)

So the process function of Damage Processor ultimately calls IDamageTarget.Damage(), so the fact that CritDamageProcessor is a subclass of DamageProcessor shouldn't be a problem, since the workflow ties back into the standard damage workflow. The whole issue seems to be a problem with the way that the PUN integration allows each client to calculate their own damage, instead of only the master client calculating damage and then informing the clients of the damage dealt. But I am not really certain where to begin making this altercation so that DamageProcessor's can modify damage amounts in a networked setting.

The Health component implements the IDamageTarget interface so at that point the damage is dealt on the client. I can see the situation though where you would instead want it to be run on the originating target or even the master client. In this situation it'll take some modification of the flow. The PunHealthMonitor.OnDamage method is called which sends the RPC to the client to do the damage. It is immediately before this method that you'll want to get the damage processor on the target and modify the damage amount before it is sent to the client.
 
Excellent! Thank you for the response.
I went ahead and did what you suggested. Using DamageProcessor as a tool to modify damage amounts in a multiplayer setting required some slight refactor of MeleeWeapon.cs (which sadly means it will require a refactor of any damaging action). The idea is that the DamageProcessor's shouldn't be used on HitCollider(), but rather in Health.Damage().

This means that the DamageProcessor is no longer being used for its "intended" workflow of triggering target.Damage(...), but rather it is just a tool to modify the DamageData before it is passed to the NetworkHealthMonitor. This does mean that ONLY the owner of the damaged health component can actually see my floating combat numbers now, but I think I just need to refactor things and not tie my floating combat numbers into the DamageProcessor.

I also added the DamageProcessor as a field to IDamageOriginator. This way its really easy to figure out what DamageProcessor to use for modifying the targets health. You just need to make sure that all the classes implementing IDamageOriginator get updated as well.

Anyways, I will just have to keep at it from here. Thank you and I appreciate the help!
 
You could extend CharacterHealth and override OnDamage/Die and send RPC to the attacker to update your floating numbers, you could also register an event that only the master will use to update.
 
Top