Hi Everyone,
I have a sequential light up game for which a player has to reach the correct target, the water the more points. There are 4 targets. One of the four targets lights up and the player has to touch that target. The target then loses its light after which the next target activates by lighting up and so on.
The sequence of activation and the light up is governed by a game_manager script.
Now after a touch I would however like the game_manager to wait N number of frames until it continues with activation. The idea is that the player then has N frames to think about which target may activate next.
Since the next activation occurs after touch I tried adding an empty while loop to line 10, to let the game wait for 250 time frames until resuming the the rest of the script. I then tried a coroutine, by also adding StartCoroutine(WatchForEnoughSteps(IntertrialIntervalDuration)); to line 10 which did not work either.
Any suggestions on how I could resolve this ? Id be happy to learn more.
private int time_steps = 0;
IEnumerator WatchForEnoughSteps(int time_steps_interval)
{
while (time_steps < time_steps_interval)
{
yield return null;
}
time_steps = 0;
ItiActive = false;
}
public void triggered(GameObject touchedSphere)
{
// if more than than 1 target object
if (targetObjects.Length > 1)
{
if (touchedSphere == targetObjects[checkActive(gameSequence)])
{
collision = true;
agent.GetComponent<ReacherAgent>().AddReward(rewardToGive);
// Suspend script for N time frames
gameSequence++;
rewardToGive = 1.0f;
failCounter = 0;
// sets the tag of GoalOn objct of the touchedSphere to Untagged
touchedSphere.transform.GetChild(0).gameObject.tag = "Untagged";
// set the color of the target back to its original
touchedSphere.GetComponent<Renderer>().material.color = temp;
if (gameSequence > 3)
{
gameSequence = 0;
failCounter = 0;
SequenceEnd = true;
if (RandomSequence == false)
{
initializeFixedRound();
SequenceEnd = false;
gameSequence = 0;
}
else if (RandomSequence == true)
{
initializeNewRound();
SequenceEnd = false;
gameSequence = 0;
}
}
else
{
int active = checkActive(gameSequence);
// sets the tag of the next balls GoalOn objct Active
targetObjects[active].transform.GetChild(0).gameObject.tag = "Active";
// save its color to temp
temp = targetObjects[checkActive(gameSequence)].GetComponent<Renderer>().material.color;
// let it light up
targetObjects[active].GetComponent<Renderer>().material.color = new Color(224, 224, 224);
}
}
else
{
// if wrong sphere fail counter increments
failCounter++;
//TODO: fail increment per frame. needs to be reduced to 1 touch per collision
}
}
}