mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 22:10:17 +00:00
using fire direction from client when trying to fire
This commit is contained in:
parent
7983812074
commit
bae6676196
2 changed files with 14 additions and 2 deletions
|
@ -16,6 +16,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
[SyncVar] GameObject m_net_playerOwnerGameObject;
|
||||
internal GameObject NetPlayerOwnerGameObject { set { m_net_playerOwnerGameObject = value; } }
|
||||
public Player PlayerOwner => Player.GetOwningPlayer(this);
|
||||
|
||||
[SyncVar(hook=nameof(Net_OnIdChanged))] int m_net_pedId = 0;
|
||||
|
||||
|
|
|
@ -415,7 +415,15 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
protected virtual bool TryFire ()
|
||||
{
|
||||
if (m_weapon != null)
|
||||
{
|
||||
if (m_isServer)
|
||||
{
|
||||
if (m_ped.IsControlledByLocalPlayer || null == m_ped.PlayerOwner)
|
||||
return this.TryFire(m_weapon.GetFirePos(), m_weapon.GetFireDir());
|
||||
else // this ped is owned by remote client
|
||||
return this.TryFire(m_weapon.GetFirePos(), m_ped.NetFireDir);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -428,6 +436,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
if (!m_isServer) // for now, do this only on server
|
||||
return false;
|
||||
|
||||
if (Net.NetStatus.IsClientOnly && ! ped.IsControlledByLocalPlayer)
|
||||
return false;
|
||||
|
||||
if (null == weapon)
|
||||
return false;
|
||||
|
||||
|
@ -461,7 +472,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
F.RunExceptionSafe( () => weapon.FireProjectile (firePos, fireDir) );
|
||||
|
||||
// send fire event to server
|
||||
if (Net.NetStatus.IsClientOnly)
|
||||
if (Net.NetStatus.IsClientOnly && ped.IsControlledByLocalPlayer)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue