So I have ma de this script for my movement but i got the problem that IEnumerator time() won’t run. I have tried to write it as. IEnumerator bool time() but is doesn’t work either. Thanks for your help.
using UnityEngine;
using System.Collections;
public class movement : MonoBehaviour {
//value for movement with keys
public float movspd = 10.0f;
public float trnspd = 100.0f;
//value for push movements
public float push = 10.0f;
public bool quickpush = true;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// This is the movement for the arrows
float move_Forward = movspd * Time.deltaTime * Input.GetAxis("Vertical");
float rotate = trnspd * Time.deltaTime * Input.GetAxis("Horizontal");
transform.Translate (Vector3.forward * move_Forward);
transform.Rotate (Vector3.up * rotate);
// Ends ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This is the movement for the sida pushes
float push_p = push * Time.deltaTime;
float push_n = -push * Time.deltaTime;
if(Input.GetKey("a") && quickpush){
transform.Translate (Vector3.right * push_p);
quickpush = false;
time();
}
if(Input.GetKey("d") && quickpush){
transform.Translate (Vector3.right * push_n);
quickpush = false;
time();
}
// Ends ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if( Input.GetButton("reset")){
transform.position = new Vector3(0,0,0);
transform.eulerAngles = new Vector3(270,0,0);
}
}
IEnumerator time(){
yield return new WaitForSeconds(2);
quickpush = true;
return;
}
}