How to stop the door rotation at 90 degree

When I start playing I want the player interact with key E and the gate rotate to 90 degree.

I did the FRotator but it keep rotating endlessly.

How to stop the rotation at 90 degree?
/*****************************************************************/
// Called every frame
void UNigtDegree_Door::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction
ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

RotatePlatform(DeltaTime);
// ...

}
void UNigtDegree_Door::RotatePlatform(float DeltaTime)
{

GetOwner()->AddActorLocalRotation(RotaionDoorVelosity *DeltaTime);

}

/*********************************************************************************************/
.h file
private:

UPROPERTY(EditAnywhere, Category ="Rotation")
FRotator RotaionDoorVelosity;              // =FRotator(0,0,90); 

 void RotatePlatform(float DeltaTime);

};

It will be appreciate if some one can help me with this regards.

Hello, if you want to stop the rotation you could count how much you rotated using the DeltaTime.

.cpp file

void UNigtDegree_Door::RotatePlatform(float DeltaTime)
{
   if (RotationAmount < 1)
   {
      GetOwner()->AddActorLocalRotation(FRotator(0, 0, 90) * DeltaTime);
      RotationAmount += DeltaTime;
   }
}

.h file

void RotatePlatform(float DeltaTime);
float RotationAmount = 0;

When the value of RotationAmount get to 1, means that the added rotation is equal to FRotator(0, 0, 90).
I hope this is useful.

Look into using the FMath::Interp functions. You can control the exact time it takes and the rotations will always be precise. It will also keep everyone working on the project sane. :smile:

FMath::InterpEaseInOut | Unreal Engine Documentation

Thank you so much.

I dont know exactly how to read Unreal Engine Documentation. I have used to program games without engine but I was creating functions which dont exists. Can you plase advice me how to get familiar with Unreal Engine Documentation?
For example GetOwner(); In my game there was nothing display/ or moved until I saw it Youtube, you need to point to the address of the Actor. In fact they didnt say it that way. That was from my humble search after I saw them using that function.

How I can know which function is to which ( Character , Pawn , Actor , Actor Component , Scene Component, etc ?

Can you tell me please? Thank you for your support.

Some quick tips that have helped me with the docs:

  • Hierarchy is very important. Link for example.
    image
    Knowing what every class can and cannot do will save you a lot of time researching how to achieve stuff. You can skim through the classes by searching for them in the content browser:
  • Give this a read: Coding Standard | Unreal Engine Documentation , specially attention to Naming Conventions to help navigate the classes.
  • Make a habit of diving into .h file and follow the chain up:
  • Don’t forget to ctrl + f when going throught the classes.

Hope it helps.

1 Like