{"record":{"id":"ad2e15b0f779cc27","repo":"stride3d/stride","slug":"please-add-a-charactercomponent-to-the-entity-containing","errorCode":null,"errorMessage":"Please add a CharacterComponent to the entity containing PlayerController!","messagePattern":"Please add a CharacterComponent to the entity containing PlayerController!","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Navigation.Tests/PlayerController.cs","lineNumber":73,"sourceCode":"        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        {\n            if (!ReachedDestination)\n            {\n                var direction = CurrentWaypoint - Entity.Transform.WorldMatrix.TranslationVector;\n                direction.Y = 0.0f;","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Navigation.Tests/PlayerController.cs#L55-L91","documentation":"PlayerController requires a CharacterComponent on the same entity to move the character via physics. In Start(), Entity.Get<CharacterComponent>() returns null, so the script throws this ArgumentException indicating the entity is missing the required character/physics component.","triggerScenarios":"Start() is called on an entity with PlayerController (and NavigationComponent) but no CharacterComponent attached.","commonSituations":"Setting up the navigation test scene without a CharacterComponent; attaching the character component to a child entity instead of the same one; renaming or removing the component after initial setup.","solutions":["Add a CharacterComponent to the same entity as the PlayerController.","Ensure the entity also has the collider/collider shape the CharacterComponent needs.","Confirm both NavigationComponent and CharacterComponent are on the PlayerController's entity.","Null-check Character before use if the scene is constructed programmatically."],"exampleFix":"// before\nentity.Add(new PlayerController());\n// after\nentity.Add(new CharacterComponent());\nentity.Add(new PlayerController());","handlingStrategy":"validation","validationCode":"if (Entity.Get<CharacterComponent>() == null)\n    throw new InvalidOperationException(\"Attach a CharacterComponent to the PlayerController entity before running.\");","typeGuard":"bool HasCharacter(Entity e) => e.Get<CharacterComponent>() != null;","tryCatchPattern":"try { playerController.Start(); } catch (ArgumentException ex) when (ex.Message.Contains(\"CharacterComponent\")) { Log.Error(\"Scene misconfigured: add CharacterComponent\"); }","preventionTips":["Add CharacterComponent together with NavigationComponent and PlayerController on one entity","Verify collider setup required by CharacterComponent","Recheck components after refactoring entities in Game Studio","Validate entity composition before running the scene"],"tags":["stride","navigation","missing-component","physics"],"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"}