Beginner struggling with character Instantiation

Grey_Mongrel

New member
I am coming at this as a beginner, I have been playing around trying to get comfortable with the character controller but have run into some snags.
Specifically I am trying to grasp the process of instantiating a character.

I have a base character with the "minimum" components on it, when it is in the scene everything works fine. The camera attaches and it all works as expected.
Currently there is the main camera that has the opsive camera scripts on it and also the game object with some opsive manager scripts on it... all good.

I removed the character from the scene and left everything else as it is.

In my own player manager I created a SpawnPlayer function that instantiates the player prefab into the world, it also grabs the cameraController reference and sets .Character to the playerPrefab. and this is where the issue occurs.

I get a constant NullReference exception from the CameraControllerHandler.GetMoveInput.....

I have tried adding in some calls to set perspective and Set view type after reading the documentation. I have also tried setting the cameraControllerHandler to active (as it deactivates on play with no character. But that also adds an input error to the logs. I have tried setting the Shared.Input.PlayerInput to the playerPrefabs component but that did nothing.

If I drop the prefab in the scene, it all works.

I feel like I am missing a rather large piece of the puzzle and searching through the associated scripts is not really helping. Am I going about this completely wrong or missing something basic?

I think I could also make the camera a prefab and instantiate it after the player, but I would like to learn the proper channels to do these things with the controller.

Thanks for any and all advice/help.
 
If you are spawning the prefab at runtime you should disable the Auto Anchor feature of the camera controller. You can then assign the character manually with cameraController.Character = yourCharacter. This page has an example:

 
Top