Answer the question
In order to leave comments, you need to log in
Why does the tail list not respond to movement, but the first element in the list does?
I don't have any errors. But when the first part of the tail "grows", i.e. the first element is supposed to work fine, but the rest don't.
public class TailAdder : MonoBehaviour
{
[SerializeField] private GameObject tailPrefab;
private GameObject _tail;
public int numerate;
public int nomerrate;
private float ourTimer;
List<GameObject> _tails = new List<GameObject>();
Move move = null;
void Start()
{
move = GetComponent<Move>();
}
void Update()
{
ourTimer += Time.deltaTime;
if (numerate == 1)
{
_tail = Instantiate(tailPrefab) as GameObject;
_tail.name = "tail" + nomerrate;
_tails.Add(_tail);
nomerrate++;
numerate = 0;
}
if (nomerrate >= 1)
{
for (int i = 0; i < nomerrate; i++)
{
_tail = _tails[i];
if (ourTimer >= 0.25f)
{
_tail.transform.position = move.previouslyPos;
_tail.transform.rotation = move.rotationPoint;
ourTimer = 0f;
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question