I am trying to move a block -1 on the x axis and have delay in between moves
public class setmove : MonoBehaviour
{
Transform trans
private void Start()
{
trans = GetComponet<Transform>();
}
private void Update()
{
if(trans.position.x != -15 { StartCoroutine(wait(20)); }
//this is here to make new block and destroy old one
if(trans.position.x <= -15 { GameObject .find("controller").GetComponet<set_make>().Start(); Destroy(this); }
private IEnumerator wait(int delay)
{
yield return new WaitForSecondsRealTime(delay);
trans.position = new vector3(trans.position.x-1, trans.position.y);
}
}
but there is no delay
i want it to wait but time in between decreases