- Home /
Adding an unkown script dynamically
Heya, I am making a game in which you choose a character and fight against each other. The thing is, I want to make a generic character and in the main menu (for now) you choose the character before you enter a game. That means I want to choose one of a few scripts I'm making ahead and add them according to what the player chose. I thought about doing like this:
Public class PlayerController:NetworkBehaviour
{
public NetworkBehaviour _addedScript = null;
Start()
{
if(_addedScrip != null)
{
gameObject.AddComponent<{?}>();
}
}
}
What do I need to add instead of the {?}? I searched across the internet and Im lost. I can't write the name of a script because I do not know what it is yet.
Your answer

Follow this Question
Related Questions
How to access the properties of any created Game Object from another script Unity C # 2D 1 Answer
Camera switch between child back to main camera issue 2 Answers
Can't add component because class doesnt exist 1 Answer
Unity networking tutorial? 6 Answers
network address automatically change to localhost if i want to host 0 Answers