- Home /
Getting gameObjects to lookAt using runtime csharp script
I've got a lookAtTarget script for a NPC instantiated at runtime through csharp script that would look at my player who is also instantiated at runtime from the project using csharp script.
However the lookAtTaget script fails because the player isn't instantiated yet.
How can I force the player character to be created through script before any NPC characters ?
Or get the lookAtTarget script to be executed after for example my setUpCharacters method ?
Use script execution order to get better control over what starts first. That, or instantiate your player in Awake, and the NPCs in Start.
I put my player in awake and NPCs in Start. It worked, thanks!
Answer by DaveA · Nov 15, 2011 at 05:21 PM
syclamoth: Use script execution order to get better control over what starts first. That, or instantiate your player in Awake, and the NPCs in Start
Your answer
Follow this Question
Related Questions
NPC flying towards me!!! 1 Answer
Talking to multiple NPC's 2 Answers
Line Renderer Collision Detection. 2 Answers
Distance to object and rotation lock 1 Answer
2D Movement Problems 2 Answers