aim toward head

This commit is contained in:
in0finite 2021-09-11 02:48:11 +02:00
parent fa825315d9
commit 167e313456

View file

@ -112,7 +112,7 @@ namespace SanAndreasUnity.Behaviours
case PedAction.Chasing:
if (this.TargetPed != null)
{
Vector3 diff = this.TargetPed.transform.position - this.MyPed.transform.position;
Vector3 diff = GetHeadOrTransform(this.TargetPed).position - GetHeadOrTransform(this.MyPed).position;
Vector3 dir = diff.normalized;
if (diff.magnitude < 10f)
{
@ -151,6 +151,11 @@ namespace SanAndreasUnity.Behaviours
}
}
private static Transform GetHeadOrTransform(Ped ped)
{
return ped.PlayerModel.Head != null ? ped.PlayerModel.Head : ped.transform;
}
private static PathNode GetNextPathNode(PathNode previousNode, PathNode currentNode)
{
var possibilities = new List<PathNode>();