Slowly spin up to a limit

Hi, first sorry for the bad english.
At first i have a script that makes my cube be rotated at one point, i would like you to help me to make it rotate slowly to the limit (90 degrees), and after that it stops rotating, without going beyond 90 the angle , it is extremely important for the project that it has an exact angle of 90 at the end of the movement, I know it seems little but I have been trying to do this for 6 hours without success.
I leave the script below

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Cube : MonoBehaviour
{
    public Transform CubeTransform;
    public Transform PFront;

    void GetInput()
    {
    }

    void Start()
    {
    }

    void FixedUpdate()
    {
        if (Input.GetKey("w"))
        {
            CubeTransform.RotateAround(PFront.transform.position, Vector3.left, 90.0f);
        }
    }

    void Update()
    {

    }

}

thanks:)

6741043--776845--upload_2021-1-19_19-3-0.png

Track your own rotation in a float variable and advance it how you like, stopping it at 90 degrees.

Each frame, set the rotation of the cube:

// if angle is your angle, and you rotate around Y, then:
CubeTransform.rotation = Quaternion.Euler( 0, angle, 0);

I did that, but it goes through the ground, I’ll explain better, I have a cube, and I would like to make it rotate on the ground around its ends, but instead everything I’ve done so far has made it have a different final rotation. of 0 , 90 , 180 , 270 , 360, which would be the shapes that it would fit perfectly into the floor

Are you just trying to roll a cube along the ground like flop-flop-flop?

If so, I got a demo of that. See attached package.

8328354–1094058–RollingACube.unitypackage (267 KB)

ah , that was it , I 'll try to understand how you did it , thank you

It makes a little invisible pivoter GameObject that it recycles over and over.

When a move command arrives, it:

  • moves the pivoter where it needs to be (on the ground at the leading edge of the cube)
  • parents the cube to it (unity takes care of the offsetting)
  • flops the pivot through 90 degrees to make the cube flop over

When it is done, it deparents the cube and starts looking for the next move command.

You can change size of cube and rate of flop through 90 degrees.