- Home /
Question about instatiating prefab/clone character and how they work/interact with non prefeb buttons
Hello,
I have a question regarding how to control a prefab/clone that has been instatiated. I am making a game where a character prefab is instatiated or "spawned" when my player (that is not a prefab) gets hit by an enemy.
When my player gets hit a UI buttons pops up (isActive). It is basically a "start" button. When I click on this button I want the instatiated character prefab to do stuff (such as follow my player) as well as my non prefab player.
I am having issues because the button can't seem to "talk" to the instatiated prefab character. As in when I try to pass a variable to the class for the character it is always null because the buttons are not prefabs. Is the best method here to make everything a prefab so they can all pass varaibles to each other? My player, the second instatiated character and the button should all be prefabs or is there a better method?
Even when I try to find the button object (findObjectOfType<>) in the character class it comes up as null.