0

I already visited many links with some possible answers but I still didn't figure out how to implement this.

I have an object inside a pivot point( actually it is a door), and I want to rotate the door by like 90 degrees and stop there, at the moment my door rotates and never stops.

I just did this:

using UnityEngine;
using System.Collections;

public class moveLastDoor : MonoBehaviour {

    private bool rotating = true;
    public void Update()
    {
        if(transform.rotation.y < 90f)
        transform.Rotate(0f,10f*Time.deltaTime,0f);

    }
}

How can I stop the rotation in a specific desired point?

Eugene Podskal
  • 10,270
  • 5
  • 31
  • 53
  • 1
    Just answered this few hours ago. Is [this](http://stackoverflow.com/a/41651803/3785314) what you are looking for? Take a look at the `RotateObject` function there. Remeber to call it once from the Start function or only when you need it in the Update function. Don't just put it in the Update function like that since it will be called again after it has finished running. – Programmer Jan 15 '17 at 15:36

1 Answers1

0

The problem is that transform.rotation is a quaternion. You should compare it this way instead: if(transform.rotation.eulerAngles.y < 90f)

Here you can find more informations about Unity's rotation and quaternions: http://answers.unity3d.com/questions/799824/oafatwhy-does-transformrotationx-45-not-work.html

Augure
  • 360
  • 3
  • 13