- Home /
got a weird error/bug
ok so i am running a basic click script that will detect a click and prevent the user from click again for about 1 second, the error/bug i am running into is that when i run my script, it says i have to wait 40 seconds. so i do so and click and then it works fine and states that the next time i can click is 42 seconds then i stop the test run, and start again expecting to have to wait 0 seconds since i restarted everything but my script starts out saying i have to wait 42 seconds. right where it left off in the last run. i am so confused why is it doing this??? how do i fix/report?? please help.
my script looks like this:
using UnityEngine; using System.Collections; using System.Collections.Generic;
public class Cube$$anonymous$$anager : $$anonymous$$onoBehaviour { public float ClickRate; public List Blocks;
float NextClick = 0;
// Use this for initialization
void Start ()
{
NextClick = 0f;
//for (int Colomb = 0; Colomb <= 9; Colomb++)
//{
for (int Row = -4; Row <= 5; Row++)
{
$$anonymous$$oreBlocks (Row, 10);
}
//}
}
public void $$anonymous$$oreBlocks(float X, float Y)
{
Instantiate (RandomBlock (), new Vector3 (X, Y, 0), Quaternion.identity);
}
public void RemoveBlock(GameObject Block)
{
print (NextClick);
if (NextClick <= Time.time)
{
print ("clicked and time");
NextClick = Time.time + ClickRate;
$$anonymous$$oreBlocks (Block.transform.position.x, 10);
Destroy (Block);
}
}
public GameObject RandomBlock()
{
return Blocks [Random.Range (0, Blocks.Count)];
}
}
Your answer
Follow this Question
Related Questions
Mirror unity: when the server loads the level the server gets disconnected 0 Answers
Fatal Error! Size overflow in allocator. Pathfinding script using NativeList's 0 Answers
How can I fix this error in my Candy Crush style game? 0 Answers
Distribute terrain in zones 3 Answers
how i -10 from thing in another code 1 Answer