Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

How would one create different player models?

Discussion in 'Editor & General Support' started by IgnisIncendio, Jul 8, 2018.

  1. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    This is a problem that has plagued me for a long time now. I have a Player.prefab, which contains all the player-related components and variables like Movement, Health, Death etc. for each of the components contain variables with things like the max health, movement speed etc.

    Now, I want to create multiple player models for the user to choose between. How do I do this?

    Option 1: Duplicate the prefabs. This is what I did in the past, not only for multiple player models but for AI/human player prefabs as well. However, this makes me lose my sanity fast. Every time I want to change something like movement speed, I need to make sure all prefabs are changed similarly.

    Option 2: Write a script that, on Awake(), spawns the models inside a root player object and then connects the references together. This is what I'm using in my newest project, but I fear this is unstable and fragile, and it's also non-visual.

    Option 3: Prefab Variants coming in 2018.3. That seems like an ideal solution; create a base player prefab, then inherit from it to create Male Player prefab, Female Player prefab etc. However, this isn't stable yet and I would like to know how people solved this problem before 2018. (Hopefully without using Option 1!)
     
  2. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
  3. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    839
    2 for now. 3 when it becomes available. 1 should only be considered if the rest of the prefab is also significantly altered between the two players and even then it might be best to avoid it.
     
  4. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Yeah, I thought so too, I'm using Option 2 currently as well (though my script is kinda like a badly implemented version of Prefab Variants). 2018.3 cannot come soon enough :)