diff --git a/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs b/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs index a55ceff0e..195ab9903 100644 --- a/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs +++ b/Assets/GothicVR/Scripts/Npc/RootCollisionHandler.cs @@ -21,10 +21,10 @@ private void OnCollisionExit(Collision coll) properties.currentAction?.OnCollisionExit(coll); // If NPC walks out of a FreePoint, it gets freed. - if (!coll.gameObject.name.StartsWithIgnoreCase("FP_")) - return; - - coll.gameObject.GetComponent().fp.IsLocked = false; + // Ignore Waypoints from WayNet as there are 4 of them which starts with FP_ but are waypoints not free points. + if (coll.gameObject.name.StartsWithIgnoreCase("FP_") && + coll.gameObject.TryGetComponent(out var vobSpotProperties)) + vobSpotProperties.fp.IsLocked = false; } /// @@ -35,10 +35,10 @@ private void OnTriggerExit(Collider coll) properties.currentAction?.OnTriggerExit(coll); // If NPC walks out of a FreePoint, it gets freed. - if (!coll.gameObject.name.StartsWithIgnoreCase("FP_")) - return; - - coll.gameObject.GetComponent().fp.IsLocked = false; + // Ignore Waypoints from WayNet as there are 4 of them which starts with FP_ but are waypoints not free points. + if (coll.gameObject.name.StartsWithIgnoreCase("FP_") && + coll.gameObject.TryGetComponent(out var vobSpotProperties)) + vobSpotProperties.fp.IsLocked = false; } private void Update() @@ -62,6 +62,5 @@ private void Update() // Empty physics based diff. Next frame physics will be recalculated. collisionTransform.localPosition = Vector3.zero; } - } -} +} \ No newline at end of file