I'm looking to have a game object rotate when the trigger on the oculus go is pressed but only then, I have the following code. Unfortunately this continuously roates even when I take my finger off the trigger,
public GameObject dummyrotate;
private bool rotate = false;
float rotationAmount = .3f;
float delaySpeed = .1f;
public void rotateAntiClockwise()
{
StartCoroutine(SlowSpin2());
}
public IEnumerator SlowSpin2()
{
float count = 0;
while (count <= 90)
{
dummyrotate.transform.Rotate(new Vector3(0,-rotationAmount,0));
count += rotationAmount;
yield return new WaitForSeconds(delaySpeed);
}
}
many thanks Jono
If you just want it to rotate while the trigger is being held, just don't use a coroutine for that. Coroutines will run until they are completely done, so instead try something like this:
public GameObject dummyrotate;
private bool rotate = false;
float rotationAmount = .3f;
float delaySpeed = .1f;
void Update()
{
SlowSpin2();
}
public void SlowSpin2()
{
if (rotate == true) {
dummyrotate.transform.Rotate(new Vector3(0,-rotationAmount,0));
count += rotationAmount;
}
}