Hi folks,
Wondering if you can help? In summary i am building a FPS style prototype and I am attempting to implement a system where for example, player A launches projectile, it hits player B and player B takes damages and player A awarded a point. My projectile is instantiated with a CoherenceSync component. To reference the client that launched the projectile, I followed the below advice (https://docs.coherence.io/coherence-sdk-for-unity/networking-state-changes/commands).
Alternatively, if you want to know which Client sent the command, you can add CoherenceSync sender as the first argument of the command, and the correct value will be automatically filled in by the SDK.
Simply put it would look like this:
Sending the command on collision:
enemyCoherenceSync.SendCommand<PlayerHealth>(nameof(PlayerHealth.OnDamage), MessageTarget.AuthorityOnly);
Receive command:
/// <summary>
/// Records the damage taken
/// </summary>
[Command]
public void OnDamage(CoherenceSync sender)
{
// Handle damage
}
However, I’m getting the below error (which makes perfect sense really), but unsure if I have the prescribed implementation correct or if I’ve got confused?
Error:
09:21:28.414 (coherence) CoherenceSync: Unable to send command ‘PlayerHealth.OnDamage’ to ‘[network] PlayerObject(Clone)’: command PlayerHealth.OnDamage() was not found. Check the command’s name and parameters, or Bake again
Note: I do have the method checked in the Coherence Sync config
SDK 1.0
Unity: 2022.3.4.f1
A broader questions would be, what would be the best practice, architecturally to implement that game behaviour that I mentioned?
Many thanks in advance!