Hello All,
I am having a problem and my question keeps getting rejected through Unity Answers. I am trying to get some code that on the first click of Lft Mouse button everything slows down, if you click Lft Mouse again with in 4 seconds you teleport to the position you clicked. I have the slow time working and the teleport working, just cannot get the two clicks to happen separately. The only way I can think of doing it is an if(GetMouseButtonDown) function with another if(GetMouseButtonDown) inside of it.This is what I have, please any help would be greatly appreciated i have been stuck on this for going on three days now.
IEnumerator JumpWait()
{
yield return new WaitForSeconds(.5f);
Player.transform.position = new Vector3(tx, ty, tz);
yield return new WaitForSeconds (.25f);
particle.particleEmitter.enabled = false;
}
IEnumerator NoJumpWait()
{
yield return new WaitForSeconds (2f);
Time.timeScale = 1f;
}
void Update()
{
if(Input.GetMouseButtonDown(0))
{
Time.timeScale = .5f;
Debug.Log("Mouse Click 1");
if(Input.GetMouseButtonDown(0))
{
Debug.Log ("Mouse Click 2");
animator.SetBool("Jump", true);
RaycastHit hitInfo;
Ray rayOrigin = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (rayOrigin, out hitInfo, maxDist))
{
tx = hitInfo.point.x;
ty = hitInfo.point.y;
tz = hitInfo.point.z;
particle.particleEmitter.enabled = true;
StartCoroutine(JumpWait());
}
StartCoroutine (NoJumpWait());
}
}
}
}