Hello. I am working on a simple project where a roulette wheel spins for a few seconds then slows to a stop using a coroutine. When I tun the program the wheel only moves a few pixels then stops. I’m thinking it has something to do with the way my IEnumerator is set up but I am not sure how to go about fixing it. The code is posted below. Thanks for any help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WheelController : MonoBehaviour
{
float rotSpeed = 0;
public float activeRotSpeed = 20f;
public float rotDecrease = 0.90f;
// Start is called before the first frame update
void Start()
{
this.rotSpeed = activeRotSpeed;
}
IEnumerator WheelCon()
{
transform.Rotate(0, 0, this.rotSpeed);
yield return new WaitForSeconds(5);
this.rotSpeed *= rotDecrease;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
StartCoroutine(WheelCon());
}
}
}