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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Animator Controller - Changing Controller based on int value

Discussion in 'Animation' started by Loff, Dec 18, 2014.

  1. Loff

    Loff

    Joined:
    Dec 3, 2012
    Posts:
    81
    Hello!

    Info:
    C#
    In the game I'm making I have a database filled with arrays like the script below. When my character is set to for example "Chosen_character = 1", it will load all ints etc below.
    If it is 1, it would load 25 health, 5 stam, 4 str, 3 armor etc.

    Code (CSharp):
    1.     [HideInInspector]public int[] base_health = new int[6] {0,25,25,25,25,25};
    2.     [HideInInspector]public int[] base_max_health = new int[6] {0,25,25,25,25,25};
    3.     [HideInInspector]public int[] base_stamina = new int[6] {0,5,4,3,6,2};
    4.     [HideInInspector]public int[] base_strength = new int[6] {0,4,3,3,2,5};
    5.     [HideInInspector]public int[] base_armor = new int[6] {0,3,4,5,3,5};
    6.     [HideInInspector]public int[] level = new int[6] {0,1,1,1,1,1};
    My Question:
    The character should be able to load the animator controller I create for the characters.
    Lets say I have one animator controller for "pig1" and one for "human1".
    "pig1" is character 1 = Chosen_character = 1.
    "human1" is character 2 = Chosen_character = 2.
    If I set "Chosen_Character = 1" it should load the pig1 animator
    --> What would be a good way to make this? I tried to use override but didn't manage to make it work, not sure if it should be used for this either.

    Any topics, links or such that I should read is very welcome, I ain't here trying to make someone solve it for me! I just want a little push forward as I'm kind of stuck. I want to understand and learn, but I don't always get the examples from the manual so I'm trying the forum.
    Cheers!
     
    Last edited: Dec 19, 2014
  2. Loff

    Loff

    Joined:
    Dec 3, 2012
    Posts:
    81
    small bump update because I'm still stuck.
    Small version: Need to swap animator (gameobject) based on int value. This should be possible or ?
    Suggestions?
     
  3. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    theANMATOR2b likes this.