My character is moving continuously. But in the game when i double click at the player he should stop and rotate 360 degrees. Then again when i double click/tap he should move in the same direction in which he was moving.
I am able to stop the player when i click 2 times but i am not able to move further.
my script is as follows
bool isMove;
float doubleClickStart = 0;
void Update ()
{
movement();
}
private void movement()
{
if(isMove)
{
transform.Translate(Vector3.forward*movementSpeed*Time.deltaTime,Space.Self);
}
}
void OnMouseUp()
{
if ((Time.time - doubleClickStart) < 0.3f)
{
this.OnDoubleClick();
doubleClickStart = -1;
}
else
{
doubleClickStart = Time.time;
}
}
void OnDoubleClick()
{
isMove = false;
Debug.Log("Double Clicked!");
}