I copied a project and it creates players using:
player = ((GameObject)Instantiate(UserPlayerPrefab, vector, quat))
.GetComponent<UserPlayer>();
UserPlayer is a script. This works, but I don’t understand the association between the script (filename is UserPlayer) and the actual game object. The project has prefab/UserPlayer which is a prefab that has a capsule mesh. I wanted to use a more complex character design, so I imported an fbx file, created a prefab from it, and added the UserPlayer script as a component. I renamed the original UserPlayerx and the new one to UserPlayer.
However, when I run the game, when the player is created, it’s still using the UserPlayerx prefab (i.e. drawing a capsule). There doesn’t seem to be any association between the UserPlayer script and the prefab except that the script is a component of the prefab, but the script is also a component of my new user player, so I’m at a complete loss.
How can I create a component using the new prefab?
In Unity, when you rename a prefab, the editor will help you out by fixing the references to that prefab in your other scene game objects. I suspect that happened here. Go to whereever you set UserPlayerPrefab in the editor and choose the new prefab.
– flaviusxvii