In this case animators contains 3 items. But let' say I don't know how many items there is. Could be 3 or 30. I can get the "medea_m_arrebola" index fine but how do I get the rest indexs ?
I tried on this line also 2 and now 1 : But getting exception IndexOutOfRangeException: Index was outside the bounds of the array.
soldiers_indexs = new int[1];
And if not using this line I'm getting null on the line :
soldiers_indexs[i] = i;
How can I get the rest items indexs ?
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OpenningScene : MonoBehaviour
{
[Header("Animators")]
public Animator[] animators;
[Space(5)]
[Header("Movement Settings")]
public Transform target;
public float movingSpeed = 1f;
public bool slowDown = false;
[Space(5)]
[Header("Rotation Settings")]
public float rotationSpeed;
public DepthOfField dephOfField;
public float waitingAnimation;
public float startConversation;
private Vector3 targetCenter;
private bool startWaitingAnim = true;
private bool endRot = false;
private int medea_m_arrebola_index;
private int[] soldiers_indexs;
// Use this for initialization
void Start()
{
targetCenter = target.GetComponent<Renderer>().bounds.center;
soldiers_indexs = new int[1];
for (int i = 0; i < animators.Length; i++)
{
animators[i].SetFloat("Walking Speed", movingSpeed);
if(animators[i].name == "medea_m_arrebola")
{
medea_m_arrebola_index = i;
}
else
{
soldiers_indexs[i] = i;
}
}
}