{"record":{"id":"85097cdc2321548c","repo":"stride3d/stride","slug":"please-add-a-navigationcomponent-to-the-entity-containing","errorCode":null,"errorMessage":"Please add a NavigationComponent to the entity containing PlayerController with the correct navigation mesh!","messagePattern":"Please add a NavigationComponent to the entity containing PlayerController with the correct navigation mesh!","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Navigation.Tests/PlayerController.cs","lineNumber":69,"sourceCode":"\n\n        private bool ReachedDestination => waypointIndex >= pathToDestination.Count;\n\n        private Vector3 CurrentWaypoint => waypointIndex < pathToDestination.Count ? pathToDestination[waypointIndex] : Vector3.Zero;\n\n        private MoveResult pendingResult;\n        private TaskCompletionSource<MoveResult> taskCompletionSource;\n\n        /// <summary>\n        /// Called when the script is first initialized\n        /// </summary>\n        public override void Start()\n        {\n            base.Start();\n\n            // Get the navigation component on the same entity as this script\n            Navigation = Entity.Get<NavigationComponent>();\n            if (Navigation == null) throw new ArgumentException(\"Please add a NavigationComponent to the entity containing PlayerController with the correct navigation mesh!\");\n\n            // Will search for an CharacterComponent within the same entity as this script\n            Character = Entity.Get<CharacterComponent>();\n            if (Character == null) throw new ArgumentException(\"Please add a CharacterComponent to the entity containing PlayerController!\");\n            \n            moveDestination = SpawnPosition;\n        }\n\n        public void Reset()\n        {\n            pathToDestination.Clear();\n            HaltMovement();\n            moveDestination = SpawnPosition;\n            Character.Teleport(SpawnPosition);\n        }\n\n        public override void Update()\n        {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Navigation.Tests/PlayerController.cs#L51-L87","documentation":"PlayerController (Stride navigation test script) requires a NavigationComponent on the same entity to receive pathfinding services. During Start(), Entity.Get<NavigationComponent>() returns null, so the script throws this ArgumentException to signal missing scene configuration.","triggerScenarios":"Start() is called on an entity that has a PlayerController script but no NavigationComponent attached in the scene editor.","commonSituations":"Forgetting to add the NavigationComponent in Game Studio; adding it to a different entity than the PlayerController; the navigation mesh not assigned in the NavigationComponent.","solutions":["Add a NavigationComponent to the same entity as the PlayerController.","Assign a built/valid navigation mesh to that NavigationComponent.","Verify in the scene editor that both components are on one entity before running.","Null-check Navigation in code if you author PlayerController variants dynamically."],"exampleFix":"// before\nEntity.Components.Add(new PlayerController()); // no NavigationComponent\n// after\nEntity.Components.Add(new NavigationComponent { NavigationMesh = myNavMesh });\nEntity.Components.Add(new PlayerController());","handlingStrategy":"validation","validationCode":"if (Entity.Get<NavigationComponent>() == null)\n    throw new InvalidOperationException(\"Attach a NavigationComponent to the PlayerController entity before running.\");","typeGuard":"bool HasNavigation(Entity e) => e.Get<NavigationComponent>() != null;","tryCatchPattern":"try { playerController.Start(); } catch (ArgumentException ex) when (ex.Message.Contains(\"NavigationComponent\")) { Log.Error(\"Scene misconfigured: add NavigationComponent\"); }","preventionTips":["Always attach NavigationComponent, CharacterComponent and PlayerController to the same entity","Assign a valid built navigation mesh in the component","Validate scene composition in an editor script or unit test before runtime","Keep scene setup scripted/templated to avoid manual mistakes"],"tags":["stride","navigation","missing-component","scene-setup"],"backgroundTag":"missing-dependency","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}