Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Help me!

Discussion in 'Animation' started by JBGamemaker, Aug 4, 2019.

  1. JBGamemaker

    JBGamemaker

    Joined:
    Dec 9, 2018
    Posts:
    21
    Im making a Call Of Duty: n@#! (Not sure if i can use that word) zombies game themed around the upcoming area 51 raid, an alternate timeline IF somewhere AROUND 300k people actually showed up and where only 4 gaurds (the rest assumed only 4 people would show up and decided it a better use of their time to spend it with friends and family) use tranquilizer pellets fired from Airsoft guns to fend of the Weebs. Now onto my problem

    while working on the windows/barriers (dont ask how OR why a (to most rational minds) NORMAL military base would have windows similar to the Zombies game mode) the first board works just fine but the second board only pop ups this error: "Invalid Layer Index: -1"

    and ive tried everything to get the 2nd board to work but it still pops up that error

    any ideas on how to solve this?

    edit: I just deleted my first version of my project where this code is contained. so BRB with similar code

    Edit 2: Now its telling me "Animator does not have animator controller" BUT i do have the code now.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class BoardActivate : MonoBehaviour
    6. {
    7.     public int boards, PreviousBoards;
    8.     public Animator[] WallFix;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         WallFix = GetComponentsInChildren<Animator>();
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         if (boards != PreviousBoards)
    19.         {
    20.             PreviousBoards = boards;
    21.  
    22.             switch (boards)
    23.             {
    24.             case 1:
    25.             WallFix[0].Play("BoardA");
    26.             return;
    27.  
    28.             case 2:
    29.             WallFix[1].Play("BoardB");
    30.             return;
    31.  
    32.             case 3:
    33.             WallFix[2].Play("BoardC");
    34.             return;
    35.  
    36.             case 4:
    37.             WallFix[3].Play("BoardD");
    38.             return;
    39.  
    40.             case 5:
    41.             WallFix[4].Play("BoardE");
    42.             return;
    43.  
    44.             case 6:
    45.             WallFix[5].Play("BoardF");
    46.             return;
    47.             }
    48.         }
    49.     }
    50. }
     
    Last edited: Aug 4, 2019
  2. JBGamemaker

    JBGamemaker

    Joined:
    Dec 9, 2018
    Posts:
    21
    NVM i think i just figured it out!