Do you mean that in Awake this variable is not initialized yet? Is this variable initialized by another script? In this case change the execution order of your scripts, to do that click on any script in project view then in the inspector click on "Execution Order..." button. Drag there any scripts you want to run in an order.
Awake is always called before AddComponent returns. If you want to initialize some variables beforehand you should either use Start or Your own function e.g. "Init" So you can do: tpc = p.AddComponent<ThirdPersonController>(); // Set some variables on tpc tpc.Init(/* maybe pass some initialization values here */); You can't create a component "manually" with new. It can only be created with AddComponent.
Do not forget the Awake (): I tried multi-line version. Awake worked before define variables I need 6 variables.
– KVinSDo you mean that in Awake this variable is not initialized yet? Is this variable initialized by another script? In this case change the execution order of your scripts, to do that click on any script in project view then in the inspector click on "Execution Order..." button. Drag there any scripts you want to run in an order.
– JixAwake is always called before AddComponent returns. If you want to initialize some variables beforehand you should either use Start or Your own function e.g. "Init" So you can do: tpc = p.AddComponent<ThirdPersonController>(); // Set some variables on tpc tpc.Init(/* maybe pass some initialization values here */); You can't create a component "manually" with new. It can only be created with AddComponent.
– Bunny83