Photon Combat Knockback [HELP] PLSS

Options
I'm trying to create a combat system with knockback, So far so good, So the knock back is not applied to clients, only the local client sees that it was applied soon afterwards the player's position does not change.

private void damageSomeone (Vector2 playerAttacker, MyPlayer player, int damageAmount) {
PhotonView target = player.gameObject.GetComponent<PhotonView>();

if (target!=null && (!target.IsMine || target.IsSceneView))
{
player.rb.velocity = (Vector2)player.transform.position + ((player.transform.position.x - playerAttacker.x) < 0 ? -1 : 1) * Vector2.one * 1.1f;

target.RPC("TakeDamage", RpcTarget.All, damageAmount,PhotonNetwork.NickName);
}
}

Comments

  • Carme
    Options
    You need to add the position move stuff into the rpc, for the remote client to be "knocked back". You should not move the remote player yourself - just in the rpc only, your local client will see the knockback by the usual method of clients position lerp synchronizing up etc etc