I simply want to return an array of the component textmesh and output the text in the scene under eachother. Because I have some turrets that i can spawn in the game, and then i have a time counter that shows when they expire and selfdestroy, so they dont stand there forever, making them too overpowered to have.
But the problem is, the timer restarts when i place a new turret down, though they still expire 10 seconds after they’ve been placed, but visually the counter resets. So what i want to achieve is to have an array or something that shows the turret cooldown under eachother. Currently the function looks like this:
public TextMesh sentryCD;
public void SetSentryCD(float cdTime)
{
sentryCD.text = "Time left
" + cdTime;
}
and then its called from the turret / sentry script.
void countDown()
{
gGui.SetSentryCD(timeLeft);
timeLeft -= Time.deltaTime;
if(timeLeft <= 0)
{
Destroy(gameObject);
}
}
I can’t really wrap my head around this. Do i use a for loop and then something like this
public textmesh[] sentrycdtime;
public void SetSentryCD(float cdTime)
{
for(int i = 0; i < sentrycdtime.Length; i++)
sentryCDtext*.text = "Time left
" + cdTime;*
}
the above code doesnt show anything
so how do i go about it? any help is appreciated