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. Dismiss Notice

Question Script That Randomizes Parts of a Character

Discussion in 'Scripting' started by EthanSaucier, Oct 8, 2023.

  1. EthanSaucier

    EthanSaucier

    Joined:
    Mar 7, 2023
    Posts:
    1
    Unity beginner here, sorry if this question's confusing.

    Let's say I wanted to have a whole bunch of characters that all wore similar uniforms but with slight variations, like a bunch of soldiers, and I had created different assets for the different parts of the uniform. How would I go about writing a script that randomized these different outfit parts for each character?
     
  2. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    Maybe use an array of Materials that you can assign to the renderer that's on each part of the character. Lots of ways to go about it, you can probably even do some trickery with tinting etc that would change color without needing multiple assets (use grayscale materials as the base).
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,054
    Essentially it‘s about enabling/disabling (respectively adding) game objects in the hierarchy of the player, or assigning different meshes or materials. Really depends on what you mean by „different assets“. Be precise with your requirements, specifically when you seek input from others. ;)