mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-03-05 07:37:17 +00:00
aim direction is synced
This commit is contained in:
parent
8eaf0c956d
commit
44c4012645
4 changed files with 23 additions and 8 deletions
Assets/Scripts
|
@ -90,7 +90,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
public bool IsAiming { get { return m_weaponHolder.IsAiming; } }
|
||||
public Weapon CurrentWeapon { get { return m_weaponHolder.CurrentWeapon; } }
|
||||
public bool IsFiring { get { return m_weaponHolder.IsFiring; } }
|
||||
public Vector3 AimDirection { get { return m_weaponHolder.AimDirection; } }
|
||||
public Vector3 AimDirection { get { return m_weaponHolder.AimDirection; } set => m_weaponHolder.AimDirection = value; }
|
||||
public bool IsAimOn { get ; set ; }
|
||||
public bool IsFireOn { get ; set ; }
|
||||
public bool IsHoldingWeapon { get { return m_weaponHolder.IsHoldingWeapon; } }
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
//[SyncVar(hook=nameof(Net_OnWeaponChanged))] GameObject m_net_weaponGameObject;
|
||||
[SyncVar(hook=nameof(Net_OnWeaponChanged))] int m_net_currentWeaponSlot;
|
||||
|
||||
[SyncVar] internal Vector3 m_net_aimDir;
|
||||
|
||||
|
||||
|
||||
void Awake_Net()
|
||||
|
|
|
@ -48,10 +48,20 @@ namespace SanAndreasUnity.Behaviours {
|
|||
|
||||
public Vector3 AimDirection {
|
||||
get {
|
||||
if (this.IsAiming && this.Camera != null)
|
||||
return this.Camera.transform.forward;
|
||||
if (m_ped.IsControlledByLocalPlayer)
|
||||
{
|
||||
if (this.IsAiming && this.Camera != null)
|
||||
return this.Camera.transform.forward;
|
||||
else
|
||||
return this.transform.forward;
|
||||
}
|
||||
else
|
||||
return this.transform.forward;
|
||||
{
|
||||
return m_ped.m_net_aimDir;
|
||||
}
|
||||
}
|
||||
set {
|
||||
m_ped.m_net_aimDir = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,19 +32,21 @@ namespace SanAndreasUnity.Net
|
|||
|
||||
}
|
||||
|
||||
public void SendInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput, bool isJumpOn, Vector3 heading)
|
||||
public void SendInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput,
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir)
|
||||
{
|
||||
this.CmdSendingInput(isWalkOn, isRunOn, isSprintOn, movementInput, isJumpOn, heading);
|
||||
this.CmdSendingInput(isWalkOn, isRunOn, isSprintOn, movementInput, isJumpOn, heading, aimDir);
|
||||
}
|
||||
|
||||
public void SendInput()
|
||||
{
|
||||
Ped ped = m_ped;
|
||||
this.SendInput(ped.IsWalkOn, ped.IsRunOn, ped.IsSprintOn, ped.Movement, ped.IsJumpOn, ped.Heading);
|
||||
this.SendInput(ped.IsWalkOn, ped.IsRunOn, ped.IsSprintOn, ped.Movement, ped.IsJumpOn, ped.Heading, ped.AimDirection);
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSendingInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput, bool isJumpOn, Vector3 heading)
|
||||
void CmdSendingInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput,
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir)
|
||||
{
|
||||
if (null == m_ped)
|
||||
return;
|
||||
|
@ -57,6 +59,7 @@ namespace SanAndreasUnity.Net
|
|||
ped.Movement = movementInput;
|
||||
ped.IsJumpOn = isJumpOn;
|
||||
ped.Heading = heading;
|
||||
ped.AimDirection = aimDir;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue