mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-16 21:08:28 +00:00
aim at chest
This commit is contained in:
parent
489e405b2d
commit
8bdfdadea7
1 changed files with 9 additions and 1 deletions
|
@ -115,13 +115,14 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
{
|
||||
Vector3 myHeadPos = GetHeadOrTransform(this.MyPed).position;
|
||||
Vector3 targetHeadPos = GetHeadOrTransform(ped).position;
|
||||
Vector3 targetChestPos = GetChestPosition(ped);
|
||||
Vector3 firePos = this.MyPed.IsAiming ? this.MyPed.FirePosition : myHeadPos;
|
||||
|
||||
Vector3 diff = targetHeadPos - myHeadPos;
|
||||
Vector3 dir = diff.normalized;
|
||||
this.MyPed.Heading = dir;
|
||||
|
||||
Vector3 aimDir = (targetHeadPos - firePos).normalized;
|
||||
Vector3 aimDir = (targetChestPos - firePos).normalized;
|
||||
|
||||
// fix for stuttering which happens when target ped is too close:
|
||||
// we assign AimDir here, which changes skeleton and therefore changes fire position, which then
|
||||
|
@ -170,6 +171,13 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
return ped.PlayerModel.Head != null ? ped.PlayerModel.Head : ped.transform;
|
||||
}
|
||||
|
||||
private static Vector3 GetChestPosition(Ped ped)
|
||||
{
|
||||
return ped.PlayerModel.UpperSpine != null
|
||||
? ped.PlayerModel.UpperSpine.position
|
||||
: ped.transform.position + new Vector3(0f, 0.3f, 0f);
|
||||
}
|
||||
|
||||
public void ChooseBestWeapon()
|
||||
{
|
||||
_ped.WeaponHolder.SwitchWeapon(this.GetBestWeaponSlot());
|
||||
|
|
Loading…
Add table
Reference in a new issue