- Home /
Lose connection to dragged variable when making prefab
I am trying to follow the tornado twins tutorials on youtube. Movie 8 i believe. The issue is when creating a cannon that follows the players movement. I can create the script and it works just fine. I drag the player character onto the script for the lookat target and it works. But, when creating a blank prefab and dragging my cannon down to the prefab, it loses the player target from the script.
Answer by GamezAtWork · Aug 16, 2011 at 02:04 AM
I don't watch their tutorials, but I don't think you can't access things on the scene from the prefabs in your project...
If you are just gonna drag it onto the scene, its simple, just assign the target after you drag it back onto the scene.
If you are planning to instantiate it using code, well, you can make it search for the target in its Awake function.
I realize there are other ways to grab a target via scripting, but i seem to be running into some weird problem that is not shown in the tutorial. Wanted to know what i was doing wrong for next time.
Your answer
Follow this Question
Related Questions
lookAt on Y axis only 1 Answer
Object Look At Mouse 2 Answers
How to force a variable to prefab 1 Answer