0
\$\begingroup\$

When my scene loads, I want to add my prefab to it along with its components.

Here is what I mean:

  1. scene loads
  2. player gender is determined via playerprefs or playfab sdk
  3. player prefab is loaded and displayed using said gender

The prefab would have a script components attached for the current data etc.

I might be approaching this wrong, but I want this to work with multiplayer in the future, so that's why I didn't just add the prefab directly to the hierarchy.

What is the correct way of doing this?

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Welcome to GDSE - what have you tried so far, and where are you getting stuck with it? Is your specific problem about instantiating prefabs, modifying them after instantiation, or something else? \$\endgroup\$
    – Joe
    Aug 12 '19 at 19:55
0
\$\begingroup\$

Can you use DontDestroyOnLoad for your player ? Maybe you could use an external script that assign what you want in your player script depending of what you want. Ex:

GameObject player;

void Start()
{
    player = GameObject.Find("player");
    if(//insert condition)
    {
        player.GetComponent<playerManager>().gender = "man";
    }
}
\$\endgroup\$
1
  • \$\begingroup\$ This answer would be better if it included a step-by-step breakdown or example code demonstrating how this strategy could be applied to solve OP's problem. \$\endgroup\$
    – DMGregory
    Aug 12 '19 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .