From 536af82beb7b059dcf96ba12ce55d10066ae3eab Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Tue, 10 Mar 2020 10:09:55 -0400 Subject: [PATCH] make NPCs stop at the edge of platforms --- Shared/NPC.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Shared/NPC.cs b/Shared/NPC.cs index 216eb46..064d463 100644 --- a/Shared/NPC.cs +++ b/Shared/NPC.cs @@ -26,8 +26,9 @@ namespace SemiColinGames { public string Update(NPC npc, float modelTime, World world) { int moveSpeed = 120; int desiredX = npc.Position.X + (int) (moveSpeed * npc.Facing * modelTime); + int testPoint = desiredX + 12 * npc.Facing; // TODO: define the box modularly & correctly. - AABB npcBox = new AABB(new Vector2(desiredX, npc.Position.Y), new Vector2(1, 33)); + AABB npcBox = new AABB(new Vector2(testPoint, npc.Position.Y), new Vector2(1, 33)); Debug.AddRect(npcBox, Color.Cyan); bool foundBox = false; foreach (AABB box in world.CollisionTargets) {