Skip to content

Commit 055bf56

Browse files
committed
fixed nearest waypoint finding?
1 parent 759d356 commit 055bf56

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

objects/obj_npc/Create_0.gml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ self.cshape = new ColSphere(new Vector3(0, self.radius, 0), self.radius);
66
self.cobject = new ColObject(self.cshape, self.id, ECollisionMasks.DEFAULT, ECollisionMasks.DEFAULT);
77
obj_game.collision.Add(self.cobject);
88

9+
self.pathfinding = undefined;
10+
911
self.IsGrounded = function() {
1012
if (self.y <= 0) return true;
1113

@@ -70,11 +72,12 @@ self.GetNearestPathfindingWaypoint = function() {
7072
var nearest_distance = infinity;
7173

7274
for (var i = 0, n = array_length(choices); i < n; i++) {
75+
var location = choices[i].data;
76+
var test_distance = point_distance_3d(self.x, self.y, self.z, location.x, location.y, location.z);
7377
if (nearest == undefined) {
7478
nearest = choices[i];
79+
nearest_distance = test_distance;
7580
} else {
76-
var location = nearest.data;
77-
var test_distance = point_distance_3d(self.x, self.y, self.z, location.x, location.y, location.z);
7881
if (test_distance < nearest_distance) {
7982
nearest_distance = test_distance;
8083
nearest = choices[i];

0 commit comments

Comments
 (0)