Player sync problem
Options
Hello everyone i have some problem with my player. when my player takes damage i am sending event with RPC and checking if health is < 0 then he is dead and disabling collision but health is synced throw OnPhotonSerializeView and it has some lag and if player clicks to many times it is counting kill point every time . have anyone some sort of workaround how to work with all this thing.
thanks for help
thanks for help
0
Comments
-
probably fixed problem with some sort of prediction if local player health is < then damage i am disabling Hit Trigger. its working but do not know how good decision is this0
-
Hi,
Check if click can kill on same client which calculates health (probably in same procedure). Send RPC to attacker if kills update required.0 -
problem is that health is synced throw the OnPhotonSerializeView() and if the rate of dealing damage is for example 10 times in sec its not fast enough to change it to damage dealer so it sends RPC 2-5 times and kill count increases.0
-
if(hit.collider.tag == "NetPlayer" &&
hit.collider.GetComponent().Health > 0)
{
if( m_Owner.Team == Team.None || hit.collider.GetComponent().Team != m_Owner.Team )
{
hit.collider.GetComponent().RPC ("TakeDamage", PhotonTargets.All,new object[]{m_WeaponController.CurrentWeapon.Damage,m_Owner.photonView.viewID});
}
}
this is the Take damage procedure and it sends it to NetPlayer
[PunRPC]
public void TakeDamage(int damage,int ID)
{
m_Health -= damage;
if(Health <= 0)
{
if(photonView.isMine)
{
PhotonView view = PhotonView.Find(ID);
PlayerKilled(view);
}
}
}
in this function.
void PlayerKilled(NetPlayer damageDealer)
{
if( m_Health <= 0 )
{
m_Health = 0;
SetVisibility( false );
if( photonView.isMine == true )
{
if( damageDealer != null )
{
damageDealer.OnKilledPlayer(this);
}
PC.m_GameModeUIController.m_CurrentGameModeUI.ShowDieMenu ();
}
}
}0 -
As I said, it does not make sense to check health on attacker side. Send "TakeDamage" always. Check if it's possible to take damage in TakeDamage method.1
-
Vadim thanks dude i have rewritten code probably everything is working thanks one more time0