My project crashes every time I try to run a certain script. I have my character running into a collider to trigger the rotation of an object for a set amount of time and unity just dies every time. I’m fairly certain that my method of rotating for a certain amount of time is what’s causing the crashing problem.
Here is the code on the collider:
public TriggerRotate spinner;
public float time;
public float speed;
public void OnTriggerEnter(Collider col){
if(col.gameObject.name == "Player"){
Debug.Log("welp");
while(Time.deltaTime*speed < time){
spinner.Trig();
Debug.Log("reached");
//Debug.Log(Time.deltaTime*speed);
}
}
}
and here is the code on the object that I want to rotate:
public Vector3 rotationVector;
bool trig;
public void Update() {
if(trig){
transform.Rotate (rotationVector);
}
}
public void Trig(){
trig=true;
}