mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 12:03:04 +00:00
send fire direction to server
This commit is contained in:
parent
a1601341e6
commit
7983812074
7 changed files with 16 additions and 9 deletions
|
@ -91,6 +91,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
public Weapon CurrentWeapon { get { return m_weaponHolder.CurrentWeapon; } }
|
||||
public bool IsFiring { get { return m_weaponHolder.IsFiring; } }
|
||||
public Vector3 AimDirection { get { return m_weaponHolder.AimDirection; } set => m_weaponHolder.AimDirection = value; }
|
||||
public Vector3 FireDirection => this.CurrentWeapon != null ? this.CurrentWeapon.GetFireDir() : this.AimDirection;
|
||||
public bool IsAimOn { get ; set ; }
|
||||
public bool IsFireOn { get ; set ; }
|
||||
public bool IsHoldingWeapon { get { return m_weaponHolder.IsHoldingWeapon; } }
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
[SyncVar(hook=nameof(Net_OnWeaponChanged))] int m_net_currentWeaponSlot;
|
||||
|
||||
[SyncVar] internal Vector3 m_net_aimDir;
|
||||
public Vector3 NetFireDir { get; set; }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -425,6 +425,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
var weapon = ped.CurrentWeapon;
|
||||
|
||||
|
||||
if (!m_isServer) // for now, do this only on server
|
||||
return false;
|
||||
|
||||
if (null == weapon)
|
||||
return false;
|
||||
|
||||
|
@ -460,7 +463,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
// send fire event to server
|
||||
if (Net.NetStatus.IsClientOnly)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// play firing sound
|
||||
|
|
|
@ -287,8 +287,8 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
public virtual void OnWeaponFiredFromServer(Weapon weapon, Vector3 firePos)
|
||||
{
|
||||
if (m_ped.IsControlledByLocalPlayer)
|
||||
return;
|
||||
// if (m_ped.IsControlledByLocalPlayer)
|
||||
// return;
|
||||
|
||||
// update gun flash
|
||||
if (weapon.GunFlash != null)
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
void StartFiring ();
|
||||
|
||||
void OnClientTriedToFire(Vector3 firePos, Vector3 fireDir);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,21 +33,21 @@ namespace SanAndreasUnity.Net
|
|||
}
|
||||
|
||||
public void SendInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput,
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, bool isAimOn, bool isFireOn)
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, Vector3 fireDir, bool isAimOn, bool isFireOn)
|
||||
{
|
||||
this.CmdSendingInput(isWalkOn, isRunOn, isSprintOn, movementInput, isJumpOn, heading, aimDir, isAimOn, isFireOn);
|
||||
this.CmdSendingInput(isWalkOn, isRunOn, isSprintOn, movementInput, isJumpOn, heading, aimDir, fireDir, isAimOn, isFireOn);
|
||||
}
|
||||
|
||||
public void SendInput()
|
||||
{
|
||||
Ped ped = m_ped;
|
||||
this.SendInput(ped.IsWalkOn, ped.IsRunOn, ped.IsSprintOn, ped.Movement, ped.IsJumpOn, ped.Heading,
|
||||
ped.AimDirection, ped.IsAimOn, ped.IsFireOn);
|
||||
ped.AimDirection, ped.FireDirection, ped.IsAimOn, ped.IsFireOn);
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSendingInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput,
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, bool isAimOn, bool isFireOn)
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, Vector3 fireDir, bool isAimOn, bool isFireOn)
|
||||
{
|
||||
if (null == m_ped)
|
||||
return;
|
||||
|
@ -61,6 +61,7 @@ namespace SanAndreasUnity.Net
|
|||
ped.IsJumpOn = isJumpOn;
|
||||
ped.Heading = heading;
|
||||
ped.AimDirection = aimDir;
|
||||
ped.NetFireDir = fireDir;
|
||||
ped.IsAimOn = isAimOn;
|
||||
ped.IsFireOn = isFireOn;
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
- shooting is inaccurate - clients should send fire event with fire pos and fire dir
|
||||
|
||||
- send fireDir with other input to server
|
||||
|
||||
- remove spamming logs:
|
||||
|
||||
- sometimes, current vehicle is null on client
|
||||
|
@ -18,7 +20,7 @@
|
|||
|
||||
***
|
||||
|
||||
- weapon sound should be 3d
|
||||
- is weapon sound 3d ?
|
||||
|
||||
***
|
||||
|
||||
|
|
Loading…
Reference in a new issue