Stop an asset from walking on GetKeyUp

So first time to post here guys.

I just wanted to ask what could be done so that the asset would stop walking for, say 1.5-2 sec., upon pressing ‘Z’
Here is what I have done for now.

if (Input.GetKeyUp (KeyCode.Z)) {
IsHitting = true;
speed = 0;
for(double i=0;i<=1.5f;i+=0.1){ Debug.Log (“Halted”); }
speed = 50.0f;
}

An immediate reply would be very much appreciated.
BTW. This is for a 2D Game. Theeenks

Use a yield WaitForSeconds(1.5) call instead.

It is giving me an error. BTW. I put it inside the void Update()

Wel, thanks for the info. I found a way around it already. Theeenksss!

Nope… It will yield every frame.
Get that stuff outside the Update loop. Usually make a boolean switch which when true calls a function. Put the yield in the function and set it back to false when the yield is completed. With C# it is a bit more complicated than UnityScript and you have to use an IEnumerator instead of a void to set up the yield… But really yield is the best method for timing without continually looping…