PedStalker can follow any ped, not just local ped

This commit is contained in:
in0finite 2019-07-08 22:04:26 +02:00
parent 69cddbea30
commit f513eff625
2 changed files with 11 additions and 8 deletions

View file

@ -13,6 +13,8 @@ namespace SanAndreasUnity.Behaviours
public float stoppingDistance = 3;
public Ped TargetPed { get; set; }
void Awake ()
@ -26,19 +28,18 @@ namespace SanAndreasUnity.Behaviours
// reset input
this.MyPed.ResetInput ();
// follow player instance
// follow target ped
if (Ped.Instance != null) {
if (this.TargetPed != null) {
Vector3 targetPos = Ped.InstancePos;
Vector3 targetPos = this.TargetPed.transform.position;
float currentStoppingDistance = this.stoppingDistance;
if (Ped.Instance.IsInVehicleSeat && !this.MyPed.IsInVehicle) {
if (this.TargetPed.IsInVehicleSeat && !this.MyPed.IsInVehicle) {
// find a free vehicle seat to enter vehicle
var vehicle = Ped.Instance.CurrentVehicle;
// var seat = Player.Instance.CurrentVehicleSeatAlignment;
var vehicle = this.TargetPed.CurrentVehicle;
var closestfreeSeat = Ped.GetFreeSeats (vehicle).Select (sa => new { sa = sa, tr = vehicle.GetSeatTransform (sa) })
.OrderBy (s => s.tr.Distance (this.transform.position))
.FirstOrDefault ();
@ -56,7 +57,7 @@ namespace SanAndreasUnity.Behaviours
}
}
} else if (!Ped.Instance.IsInVehicle && this.MyPed.IsInVehicleSeat) {
} else if (!this.TargetPed.IsInVehicle && this.MyPed.IsInVehicleSeat) {
// target player is not in vehicle, and ours is
// exit the vehicle

View file

@ -16,6 +16,8 @@
- port the whole UI to multiplayer
- fix connection timeout bug
- create weapon prefab ; add it to spawnable prefabs list ;