Day #007

DAY #007

make a countdown to an action

Main points covered

#Time.deltaTime

C# script (attached to the object)

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class rotateCube : MonoBehaviour {

public float speed;

private float spinningTime = -1.0f;
public float countdown = 1.0f;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

countdown -= Time.deltaTime;

Debug.Log (countdown);

if (countdown <= 0.0f) {
transform.Rotate (Vector3.up * speed * Time.deltaTime);
if (countdown < spinningTime) {
print (“rotating is done”);
countdown = 1.0f;
}
}
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *