Question by
stephanlevin · Jul 13, 2017 at 10:39 AM ·
scripting problemscripting beginnertimerdelayscritping
script delay ("on mouseclick")
hey guys! i have an object which is auto-spinning and you can rotate it around the y-axis by draging it. i want to have an delay of 10 seconds; so whenever i drag the object and rotate it, it should stop 'auto-spinning' for 10 seconds and then go on normally with the auto-spin. here is the script:
using UnityEngine;
using System.Collections;
public class tes01 : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector2(Time.deltaTime * 0f, 0.05f));
}
float rotSpeed = 8;
void OnMouseDrag()
{
if (Input.mousePosition.y < Screen.height / 2)
{
float rotX = Input.GetAxis("Mouse X") * rotSpeed * Mathf.Deg2Rad;
transform.RotateAround(Vector2.up, rotX);
}
}
}
any ideas of how i could do this? would really thankful if you could give me a finished script for that because i'm new to c# - thank you!
Comment